tabBar与状态栏

来源:互联网 发布:ubuntu golang 1.8 编辑:程序博客网 时间:2024/06/06 21:44
一些基本的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 实现:

    1. 需要将图片放到一个.xcassets中才可以使用【前提】
    2. 在***.xcassets中选中图片
    3. 在右侧选择attributes inspector  
    4. 在快到下面有一个选项为Render As Default 
    5. 只需要将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实现
    1. 在storyboard中找到tabBarViewController中找到的自己的tabBar
    2. 在identify inspector中找到User Defined Runtime Attributes(点击框框左下角的加号新加一个属性值)
    3. 添加如下:
    4. 设置如下:
keyPath TypeValue
selectedImageTintColor  Color  【你需要的颜色】      

0 0
原创粉丝点击