简体   繁体   中英

iOS 7 change tabBar selected icon

I've created a tabBar in storyboard and set a custom image. I want to use a different image for the "selected" state, I know I can't set that image using storyboard but how do I do it programmatically?

I also want to change the icon tint colour in code but can't make that happen either.

I would significantly appreciate any help please.

Try this in you AppDelegate.m file

[tbc.tabBar setSelectionIndicatorImage:[UIImage imageNamed:@"YOUR_IMAGE_NAME.png"]];

where tbc - you TabBarController

UIStoryboard *iPhoneSB = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil];
    CustomTabBarController *tbc = [iPhoneSB instantiateInitialViewController];

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