EGH*_*HDK 64 interface-builder ios ios6 ios7
我想改变导航栏颜色的颜色,但我不确定是否应该改变色调或背景.我知道iOS 7将采用更平面的设计(甚至建议删除渐变),但我无法破译这两个.即使我设置了背景颜色,也没有做任何事情.
在此图像中,背景设置为绿色,但条形仍为蓝色:
小智 107
在iOS 7.0上,tintColor对条形的行为已经改变.它不再影响条形图的背景,其行为与添加到UIView的tintColor属性的描述相同.要为条形图的背景着色,请使用-barTintColor.
navController.navigationBar.barTintColor = [UIColor navigationColor];
car*_*ich 79
如果你想在iOS 6中使用类似于iOS 7的导航栏的纯色,请使用:
[[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setBackgroundColor:[UIColor greenColor]];
Run Code Online (Sandbox Code Playgroud)
在iOS 7中使用barTintColor
如下:
navigationController.navigationBar.barTintColor = [UIColor greenColor];
Run Code Online (Sandbox Code Playgroud)
要么
[[UINavigationBar appearance] setBarTintColor:[UIColor greenColor]];
Run Code Online (Sandbox Code Playgroud)
Ash*_*ish 36
//在ios 7中: -
[self.navigationController.navigationBar setBarTintColor:[UIColor yellowColor]];
Run Code Online (Sandbox Code Playgroud)
//在ios 6中: -
[self.navigationController.navigationBar setTintColor:[UIColor yellowColor]];
Run Code Online (Sandbox Code Playgroud)
Cha*_* A. 11
背景颜色属性在a上被忽略UINavigationBar
,因此如果要调整外观,则必须使用tintColor
或调用UINavigationBar类引用的 "自定义条形外观"下列出的一些其他方法(如setBackgroundImage:forBarMetrics:
).
请注意,该tintColor
属性在iOS 7中的工作方式不同,因此如果您希望使用背景图像在iOS 7和之前版本之间保持一致的外观可能是您最好的选择.另外值得一提的是,你不能配置故事板的背景图片,你必须创建一个IBOutlet
你UINavigationBar
并改变它在viewDidLoad
或其他一些适当的地方.
还有一件事,如果你想在UIPopover中更改导航bg颜色,你需要设置barStyle
为UIBarStyleBlack
if([UINavigationBar instancesRespondToSelector:@selector(barTintColor)]){ //iOS7
navigationController.navigationBar.barStyle = UIBarStyleBlack;
navigationController.navigationBar.barTintColor = [UIColor redColor];
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
118365 次 |
最近记录: |