How to change tintColor UIBarButtonItem in Swift?

I want to change the color of an element of the right-hand panel button from black to white. This is a button in the form of a search icon. I have not encoded the search implementation yet, since I want to get the main interface first. I thought I wrote the correct codes to make it look white, but it still appears black in both the storyboard and the simulator.

In the storyboard, I also set it to white.

Here is my code which is in the AppDelegate.swift file:

 func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Changing the status bar colour to white UIApplication.sharedApplication().statusBarStyle = .LightContent // Changing the navigation controller background colour UINavigationBar.appearance().barTintColor = UIColor(red: 0.0/255.0, green: 165.0/255.0, blue: 227.0/255.0, alpha: 1.0) // Changing the navigation controller title colour UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName: UIColor.whiteColor()] // Changing the colour of the bar button items UINavigationBar.appearance().tintColor = UIColor.whiteColor() // Changing the tint colour of the tab bar icons UITabBar.appearance().tintColor = UIColor(red: 0.0/255/0, green: 165.0/255.0, blue: 227.0/255.0, alpha: 1.0) return true } 

Here is the simulator image:

enter image description here

It seems strange to me that this line of code does not work. Any solution?

+7
ios swift uinavigationitem uinavigationcontroller uinavigationbar
source share
1 answer

The problem was that the button was automatically configured as a user button. I rebuilt it in the system.

0
source share

All Articles