标签栏代码

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u010105969/article/details/48895625

- (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 = titles[index];         index++;     } }  // 设置导航条的颜色     [[UINavigationBar appearance] setBarTintColor:[UIColor orangeColor]];     // 设置状态栏字体颜色     [application setStatusBarStyle:UIStatusBarStyleLightContent];     // 设置导航栏title颜色和字体     NSDictionary* textAttributes = @{                                      NSFontAttributeName : [UIFont systemFontOfSize:25],                                      NSForegroundColorAttributeName : [UIColor greenColor],                                      };     [[UINavigationBar appearance] setTitleTextAttributes:textAttributes];

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

相关文章

扫码关注云+社区

领取腾讯云代金券