首页 > 代码库 > iOS tabbar 属性
iOS tabbar 属性
1.设置tabbar背景颜色
1 NSArray *controllers = [NSArray arrayWithObjects:nav_main,nav_channle,nav_me, nil]; 2 _tabController.viewControllers = controllers; 3 _tabController.delegate = self; 4 5 for (int i=0;i<self.tabController.viewControllers.count;i++) { 6 UIViewController *viewController = [self.tabController.viewControllers objectAtIndex:i]; 7 // 设置tabbar 背景颜色 8 [viewController.tabBarController.tabBar setBackgroundImage:[UIImage imageWithColor:kTabBarBackgroundColor]]; 9 }
2.ios7.ios6选中 未选中颜色
[[UITabBarItem appearance]setTitleTextAttributes:@{ UITextAttributeTextColor : cMainColor }
forState:UIControlStateSelected];
[[UITabBarItem appearance] setTitleTextAttributes:@{ UITextAttributeTextColor : cTabUnselect }
forState:UIControlStateNormal];
以下添加font属性
[[UITabBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue-Bold" size:10.0f], NSForegroundColorAttributeName : appTintColor } forState:UIControlStateSelected]; // doing this results in an easier to read unselected state then the default iOS 7 one [[UITabBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue-Bold" size:10.0f], NSForegroundColorAttributeName : [UIColor colorWithRed:.5 green:.5 blue:.5 alpha:1] } forState:UIControlStateNormal];
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。