关于UITabBar配置

简介:

为了适配6.0版本,需要做额外处理,同时由于7.0版本以后新增了一些API,如果没有注意到这些变化,

设置了图片并没有达到预期的效果。


下面是关键代码,适配了6.0:


  UITabBarItem *item2 = [[UITabBarItem alloc] init];
  item2.title = @"消息";
  if (kIOSVersion >= 7) {
    item2.image = [kImageWithName(@"messageUnselect") imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    item2.selectedImage = [kImageWithName(@"messageSelected") imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

    [item2 setTitleTextAttributes:@{NSForegroundColorAttributeName : kAssistOrangeColor}
                         forState:UIControlStateSelected];
    [item2 setTitleTextAttributes:@{NSForegroundColorAttributeName : kBColor}
                         forState:UIControlStateNormal];
  } else {
    [item2 setFinishedSelectedImage:kImageWithName(@"messageSelected")
        withFinishedUnselectedImage:kImageWithName(@"messageUnselect")];

    [item2 setTitleTextAttributes:@{UITextAttributeTextColor : kAssistOrangeColor}
                         forState:UIControlStateSelected];
    [item2 setTitleTextAttributes:@{UITextAttributeTextColor : kBColor}
                         forState:UIControlStateNormal];
  }


目录
相关文章
|
10月前
CollectionView 单个选项卡的滑动
最近在做一个旅行类的项目,里面哟孤儿横向滑动的选项卡功能,乍一看设计图,感觉很简单。横向滑动,CollectionView的flowLayout有这个设置属性,分分钟搞定。后来需求要每次滑动一个选项卡。这就让我有点棘手了,因为心里知道这个应该是要自己去计算偏移量的问题了
UINavigationBar-使用总结
UINavigationBar-使用总结
84 0
UITabBarController 获得selecdIndex
UITabBarController 获得selecdIndex
58 0
|
iOS开发
修改UISearchBar背景颜色
修改UISearchBar背景颜色
139 0
|
容器
(三)UITabBarController和UITabBar的基本用法
(三)UITabBarController和UITabBar的基本用法
268 0