zoukankan      html  css  js  c++  java
  • storyboard tabbarcontroller设置tab的图片

    在storyboard里逐项设置了图片,咦,怎么是颜色?别急,慢慢来

    找到你的tabbarcontroller指向的viewcontroller,在viewdidload里做如下事,搞定

     1 - (void)viewDidLoad {
     2     [super viewDidLoad];
     3  
     4     UITabBar *tabBar = self.tabBar;
     5 
     6     
     7     UIView *backView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tabBar.frame.size.width, tabBar.frame.size.height)];
     8     backView.backgroundColor = [UIColor whiteColor];
     9     [tabBar insertSubview:backView atIndex:0];
    10     
    11     UITabBarItem *item0 = [tabBar.items objectAtIndex:0];
    12     UITabBarItem *item1 = [tabBar.items objectAtIndex:1];
    13     UITabBarItem *item2 = [tabBar.items objectAtIndex:2];
    14     UITabBarItem *item3 = [tabBar.items objectAtIndex:3];
    15     
    16     item0.image = [[UIImage imageNamed:@"shouye2"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    17     item0.selectedImage = [[UIImage imageNamed:@"shouye1"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    18 
    19     item1.image = [[UIImage imageNamed:@"shoucang2"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    20     item1.selectedImage = [[UIImage imageNamed:@"shoucang1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    21 
    22     item2.image = [[UIImage imageNamed:@"xiaoxi2"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    23     item2.selectedImage = [[UIImage imageNamed:@"xiaoxi1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    24 
    25     item3.image = [[UIImage imageNamed:@"wode2"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    26     item3.selectedImage = [[UIImage imageNamed:@"wode1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    27     
    28     
    29     [[UITabBarItem appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
    30                                                         [UIColor redColor],
    31                                                         UITextAttributeTextColor, nil] forState:UIControlStateSelected];
    32 }
  • 相关阅读:
    Excel Add-in
    并发控制MsSql
    Kaggle实战分类问题2
    NuGet
    Pomelo分布式游戏服务器框架
    Ambari
    oracle 多行转多列查询
    Oauth2.0 用Spring-security-oauth2
    bug排查小结
    Linux之lsof命令
  • 原文地址:https://www.cnblogs.com/decwang/p/4920850.html
Copyright © 2011-2022 走看看