个性化定制statusBar,UINavigationBar背景和颜色

来源:互联网 发布:linux系统时间设置 编辑:程序博客网 时间:2024/05/08 18:42

定制statusBar的字体颜色为白色(默认为黑色):

显示效果如下:


首先在info.plist里添加一项View controller  - based status bar appearance,并设置为NO


最后添加如下代码就可以了:

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

设置UINavigationBar的背景颜色和字体颜色:

效果:


代码:

//设置背景色[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:0.082 green:0.635 blue:0.188 alpha:1]];//设置字体颜色NSDictionary *navbarTitleTextAttributes = @{NSForegroundColorAttributeName:[UIColor whiteColor]};[[UINavigationBar appearance] setTitleTextAttributes:navbarTitleTextAttributes];[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];

设置UITabBar:


[[UITabBar appearance] setTintColor:[UIColor colorWithHex:0x15A230]];[[UITabBar appearance] setBarTintColor:[UIColor colorWithHex:0xE1E1E1]];[[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithHex:0x15A230]} forState:UIControlStateSelected];

第一行是选中颜色,第二行是背景色,第三行是选中后字体的颜色.

0 0
原创粉丝点击