一些基本的statusBar与NavigationBar的使用 1. 修改回退按钮的颜色: storyboard:可以上要回退到即显示回退按钮页面的前一个页面设置,如果是storyboard,选择navigationBar,在Interface Builder Document中找到Global Tint修改成自己想要的颜色即可。 代码:
[self.navigationController.navigationBar setTintColor: [UIColor yellowColor]];
可参考: http://www.2cto.com/kf/201403/285887.html
2. 如果直接取tabBar的tintColor,发现贴出来后不一样,原因可能是其设置颜色设置了translucent(半透明),默认是选中,的,如果选中后,则会出现颜色搭配经过了透明化,而且保证了下面视图的view尺寸不变,如果取消了这个效果,就会导致view的实际视图身下偏移。 可参考: http://www.cocoachina.com/bbs/read.php?tid=280826
3.在tabBar上如果我们实现了图片的渲染那么自己定义的一些如果有颜色的图片就会被默认的蓝色所取代,所以我们有时是需要将渲染的效果去掉才好。 storyboard上是不可以直接通过调整属性设置图片显示渲染效果,只能通过代码实现: 实现图片不添加渲染有两种效果,一种是通过代码如下
UIImage *image = [UIImage imageNamed:@"home"];
image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
UITabBarItem *item = [[UITabBarItem alloc] initWithTitle:@"首页" image:image tag:1];
self.tabBarItem = item; // 设置图片没有经过渲染 self.tabBarController.tabBar.tintColor = [UIColor redColor]; // 设置选中的文字效果及图片颜色(如果图片有经过渲染的话)
二、通过storyboard 实现:
-
- 需要将图片放到一个.xcassets中才可以使用【前提】
- 在***.xcassets中选中图片
- 在右侧选择attributes inspector
- 在快到下面有一个选项为Render As Default
- 只需要将Default改为Original Image即为不需要渲染。
4. 如果想实现将tabBar中Item的文字颜色改变有两种方法:
一: 代码实现,如果想实现全局颜色改变可以在**appdelegate.h中didFinishLaunch 中添加如下(想局部就需要自己在控制器所使用的Item中设置)
[[UITabBarItem appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName:[UIColor lightGrayColor]} forState:UIControlStateNormal];
[[UITabBarItem appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName:[UIColor orangeColor]} forState:UIControlStateSelected];
二: storyboard实现
-
- 在storyboard中找到tabBarViewController中找到的自己的tabBar
- 在identify inspector中找到User Defined Runtime Attributes(点击框框左下角的加号新加一个属性值)
- 添加如下:
- 设置如下:
keyPath Type ValueselectedImageTintColor Color 【你需要的颜色】