I have a UINavigationItem
, but I can't found anything beside tittle, prompt, and back button in attribute inspector
I wonder how can I change my UINavigationItem
background color using code? or programmatically?
In order to change the hub navigation bar color, we can go to site settings of hub site>Change the look>under the header section>Background> select a theme color to change the background color of your site header.
navigationController. navigationBar. barTintColor = UIColor. newBlueColor() and of course this just changes the colour of the navigation bar of the view controller that the code is within.
You can change it through code...
For Objective-C:
self.navigationController.navigationBar.barTintColor = [UIColor redColor];
Write Above line in viewDidLoad method.
For Swift:
self.navigationController?.navigationBar.barStyle = UIBarStyle.BlackTranslucent
self.navigationController?.navigationBar.barTintColor = UIColor.redColor();
OR
self.navigationController!.navigationBar .setBackgroundImage(UIImage .new(), forBarMetrics: UIBarMetrics.Default)
self.navigationController!.navigationBar.shadowImage = UIImage .new();
self.navigationController!.navigationBar.translucent = true;
self.navigationController!.navigationBar.backgroundColor = UIColor.redColor();
You can change color on your own choice.
To change the bar Text...
navigationController.navigationBar.titleTextAttributes = [UITextAttributeTextColor: UIColor.blueColor()]
See the Link.... Here
See the above image... you like output like this screen right...!!!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With