简体   繁体   中英

How to set tabbar image color ios button?

i create a 4 button like tabbar , but image show as colored ,i need show images as like tabbar image color (gray) . Thanks

Set the icon to the tabbar like this

self.tabBarItem.image = [UIImage imageNamed:@"myImage"];

Don't use

[self.tabBarItem setFinishedSelectedImage:selectedImage withFinishedUnselectedImage:unselectedImage];

because then the image will not be automatically styled to the default tabbar style

You just need to set the image mask (gray, 1 color image with the transparency), not the complete image. According to the documentation

A custom icon that you provide for a toolbar, navigation bar, or tab bar is also known as a template image, because iOS uses it as a mask to create the icon you see in your app. It is not necessary to create a full-color template image.

See for more info: http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/MobileHIG/IconsImages/IconsImages.html%23//apple_ref/doc/uid/TP40006556-CH14-SW1

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