StoryBoard 设置TabBar SelectImage 和tintColor

 

如图:StoryBoard 结构是 Tabbar + Navi + ViewControllerspa

需求:须要修改TabBar的Image 和SelectImagecode

 

设置Image blog

设置SelectImage 方式一图片

设置SelectImage 方式二it

新建一个 UITabBarController StoryBoard 中的TabBar Class选择 新建的UITabBarControllerio

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    UITabBarItem *tabBarItem1 = [self.tabBar.items objectAtIndex:0];
    tabBarItem1.selectedImage = [UIImage imageNamed:@"menu01on"];
    
}

运行看选中的图片是OK 可是 图片颜色怎么是颜色。。。。。 不要着急 代码修改以下就OK了class

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    // 设置TabBar tintColor
    // 方式一
    self.tabBar.tintColor = [UIColor colorWithRed:255/255 green:0/255 blue:0/255 alpha:1];
    
    // 方式二 Tab Bar User Defined Runtime Attributes
    /*Key Path:tintColor Type:Color Value:color*/
    
    // 方式一
    UITabBarItem *tabBarItem1 = [self.tabBar.items objectAtIndex:0];
    tabBarItem1.selectedImage = [UIImage imageNamed:@"menu01on"];
 
}
相关文章
相关标签/搜索