简体   繁体   中英

Change Unselected Tabbar item color using storyboard

I need to know how to change unselected item colour on tab bar using storyboard. I am able to change colour of selected item but the colour of unselected item is not change. So please let me know how to do this thing in objective C.

It seems you like a newbie. In storyboard, selected on tab bar item that can be change on the right panel, choose the color on the state which both selected and unselected. In code, go to the definition of UITabBarItem , of these two methods can help you and the code below.

- (instancetype)initWithTitle:(nullable NSString *)title image:(nullable UIImage *)image tag:(NSInteger)tag;
- (instancetype)initWithTitle:(nullable NSString *)title image:(nullable UIImage *)image selectedImage:(nullable UIImage *)selectedImage NS_AVAILABLE_IOS(7_0);

I think what you need is

[[self.tabBar.items objectAtIndex:index] setSelectedImage:[[UIImage imageNamed:@"image"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];

but it would be better if you share code

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM