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"];
 
}
相關文章
相關標籤/搜索