Change the color of the navigation controller

I want to change the color of the hue controller of the navigation bar to the color: R: 73, G: 155, B: 255, A: 0.7

So far, I have only been able to change it to colors in the system. Here is an example in the delegate:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool { UINavigationBar.appearance().barTintColor = UIColor.blueColor() UINavigationBar.appearance().tintColor = UIColor.whiteColor() return true } 

In addition, I would like to be able to change the title color of the navigation controller for white too!

If possible, I want to change the hue color of the tab strip to R: 73, G: 155, B: 255, A: 0.7 and their texts to white.

+6
source share
1 answer

If you want to set the background color of the navigation bar:

 UINavigationBar.appearance().barTintColor = UIColor.redColor() 

Note. RGB values โ€‹โ€‹are from 0.0 to 1.0, so you need to divide them by 255 or your color will be just white. The following shade:

 UINavigationBar.appearance().tintColor = UIColor(red: 73.0 / 255.0, green: 155.0 / 255.0, blue: 255.0/ 255.0, alpha: 1.0) 

Then, to set the title text:

 UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName: someColor, NSFontAttributeName: someFont] 

Finally, for panel items:

 UIBarButtonItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: color, NSFontAttributeName: buttonFont], forState: UIControlState.Normal) 
+11
source

Source: https://habr.com/ru/post/979522/


All Articles