版权声明:本文为博主原创文章,未经博主允许不得转载。 https://cloud.tencent.com/developer/article/1338173
- (void)customizeTabBarForController:(RDVTabBarController \*)tabBarController { UIImage *finishedImage = UIImage imageNamed:@"tabbar_selected_background";
UIImage *unfinishedImage = UIImage imageNamed:@"tabbar_normal_background";
NSArray *tabBarItemImages = @@"tabbar_limitfree", @"tabbar_reduceprice", @"tabbar_appfree",@"tabbar_subject",@"tabbar_rank";
NSArray *titles = @@"我的主页",@"粉丝列表",@"我的微博",@"关注列表",@"我的";
NSInteger index = 0;
NSDictionary *textAttributes_normal = nil;
NSDictionary *textAttributes_selected = nil;
if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_6_1) {
textAttributes_normal = @{
NSFontAttributeName: UIFont systemFontOfSize:12,
NSForegroundColorAttributeName: UIColor colorWithRed:65/255.0 green:65/255.0 blue:65/255.0 alpha:1.0,
};
textAttributes_selected = @{
NSFontAttributeName: UIFont systemFontOfSize:12,
NSForegroundColorAttributeName: UIColor colorWithRed:14/255.0 green:154/255.0 blue:255/255.0 alpha:1.0,
};
}
for (RDVTabBarItem *item in [tabBarController tabBar items]) {
item.unselectedTitleAttributes = textAttributes_normal;
item.selectedTitleAttributes = textAttributes_selected;
item setBackgroundSelectedImage:finishedImage withUnselectedImage:unfinishedImage;
UIImage *selectedimage = [UIImage imageNamed:[NSString stringWithFormat:@"%@_press",
tabBarItemImages objectAtIndex:index]];
UIImage *unselectedimage = [UIImage imageNamed:[NSString stringWithFormat:@"%@",
tabBarItemImages objectAtIndex:index]];
item setFinishedSelectedImage:selectedimage withFinishedUnselectedImage:unselectedimage;
item.title = titlesindex;
index++;
}
}
// 设置导航条的颜色
[UINavigationBar appearance setBarTintColor:UIColor orangeColor];
// 设置状态栏字体颜色
application setStatusBarStyle:UIStatusBarStyleLightContent;
// 设置导航栏title颜色和字体
NSDictionary* textAttributes = @{
NSFontAttributeName : UIFont systemFontOfSize:25,
NSForegroundColorAttributeName : UIColor greenColor,
};
[UINavigationBar appearance setTitleTextAttributes:textAttributes];