简体   繁体   中英

Swift: Change the image tint color of tab bar?

I have created the tabBarController programmatically and I want to change color of tint color of images (not the bar) that tab contains. Can anyone tell me how to do that in Swift?

In your 'application:didFinishLaunchingWithOptions'

(window?.rootViewController as! UITabBarController).tabBar.tintColor = UIColor.red

or use appearance delegate.

UITabBar.appearance().tintColor = UIColor.red

Another good solution:

Add Runtime Color attribute named "tintColor" .

It will change image tint color as well as title tint color.

在此处输入图片说明

在此处输入图片说明

Go to AppDelegate.swift file. In 'application:didFinishLaunchingWithOptions' write:

UITabBar.appearance().unselectedItemTintColor = UIColor.red

All above answers are right here I am sharing to achieve this using story board inspector

select your tab bar go to inspector and change image tint to your corresponding colour for reference attaching image

在此处输入图片说明

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