码迷,mamicode.com
首页 > 移动开发 > 详细

关于iOS Tabbar的一些设置

时间:2015-06-11 16:51:50      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:ios   tabbar   

其实iOS Tabbar的可定制性非常高,我们没有必要重复造轮子,下面是笔者收集的一些tabbar的常用设置,希望对大家有所帮助。

设置tabbar选中颜色

iOS7设置如下:

[self.tabBarController.tabBarsetSelectedImageTintColor:[UIColor greenColor]];

ios8中如下设置:

self.tabBar.tintColor=[UIColor greenColor];


消除tabbar边框

在appdelegate的程序启动处:

[[UITabBar appearance] setShadowImage:[[UIImage alloc]init]];

[[UITabBar appearance] setBackgroundImage:[[UIImage alloc]init]];


设置tabbar item原始图标与原始选中图标,而不是系统自动填充的颜色

    // 拿到 TabBar 在拿到想应的item
    UITabBar *tabBar = _tabBarController.tabBar;
    UITabBarItem *item0 = [tabBar.items objectAtIndex:0];
    UITabBarItem *item1 = [tabBar.items objectAtIndex:1];
    UITabBarItem *item2 = [tabBar.items objectAtIndex:2];
    UITabBarItem *item3 = [tabBar.items objectAtIndex:3];
    // 对item设置相应地图片
    item0.selectedImage = [[UIImage imageNamed:@"recognize-1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];;
    item0.image = [[UIImage imageNamed:@"recognize"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
     
    item1.selectedImage = [[UIImage imageNamed:@"life-1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];;
    item1.image = [[UIImage imageNamed:@"life"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
     
    item2.selectedImage = [[UIImage imageNamed:@"edit-1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];;
    item2.image = [[UIImage imageNamed:@"edit"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
     
    item3.selectedImage = [[UIImage imageNamed:@"setting-1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];;
    item3.image = [[UIImage imageNamed:@"setting"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];


设置tabbar背景图片

    UIView *backView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Main_Screen_Width, 49)];
    backView.backgroundColor = [UIColor redColor];
    [self.tabBar insertSubview:backView atIndex:0];
    self.tabBar.opaque = YES;


关于iOS Tabbar的一些设置

标签:ios   tabbar   

原文地址:http://blog.csdn.net/xanxus46/article/details/46459005

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!