【发布时间】:2012-01-17 19:13:54
【问题描述】:
在我的应用程序的应用程序委托中,我调用以下方法:
- (void)customizeAppearance
{
UIImage *gradientPortrait = [[UIImage imageNamed:@"gradient_portrait"]
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
UIImage *gradientLandscape = [[UIImage imageNamed:@"gradient_landscape"]
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
[[UINavigationBar appearance] setBackgroundImage:gradientPortrait
forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setBackgroundImage:gradientLandscape
forBarMetrics:UIBarMetricsLandscapePhone];
}
此代码允许自定义应用程序中的所有导航栏。因为我使用的图像是绿色的,所以每个条都变成绿色。
现在我的目标是为特定导航栏覆盖上述配置。
特别是,在应用程序生命周期中,我使用UIModalPresentationFormSheet 表示样式打开了一个模态控制器。此控制器显示在 UINavigationController 中。由于我还需要显示与 UINavigationController 相关的导航栏,我想知道如何在不更改我在应用程序委托中设置的全局配置的情况下自定义该栏。
我尝试将导航栏的tintColor 属性(以模态方式呈现)设置为[UIColor blackColor],并将barStyle 设置为UIBarStyleBlack,但它们不起作用。只有 barbutton 项目受到影响。
提前谢谢你。
P.S.我使用的是 iOS 5
【问题讨论】:
-
查看这个 SO 主题:stackoverflow.com/questions/8459821/…
-
@KrishnaK 感谢您的回复。我可以在我的自定义方法中使用该方法吗?
-
你应该可以在那里使用它。
标签: ios ios5 uinavigationbar styling appearance