How do I change the colour of the top bar of the customisation page of the more view controller. Please see the linked image. Sorry I can't post image here because of my low reputation.
Screenshot Image
Edited with more info:
I have managed to change the background color using the following code. But cant change the color of the top bar.
func tabBarController(tabBarController: UITabBarController, willBeginCustomizingViewControllers viewControllers: [AnyObject]) {
var editView : UIView = tabBarController.view.subviews[1] as! UIView
editView.backgroundColor = UIColor.blackColor()
}
Basically 2 Ways you can achieve this if you are using Global Unique colour in the app for All navigation bar
Use this Solution on App Launch:
UINavigationBar.appearance().barTintColor = UIColor.redColor()
Or if you want to change the Color of More navigationcontroller only then
Use this Solution by getting the Tabbar Reference :
self.tabBarController?.moreNavigationController.navigationBar.barTintColor = UIColor.greenColor()
You can use second solution in the First viewcontroller of the Tab, because that contains your tabbar reference
Related
I'm using UITab bar. In my UITabbar have 4 items and each of tabbar have navigation controller.
i want to put gradient color in the status background of view controller in 1-3 items but in view controller 4 i want it to have a status clear background.
my problem is when i go to tab 1-3 and then go to tab 4 the status background color will change according to the of tab 1-3. But I want the status background color of tab 4 is transparent.
the code that I use to change color of status background in tab 1-3
if let status = UIApplication.shared.value(forKey: "statusBar") as? UIView {
status.setGradientBackground(colorOne: Colors.carmine, colorTwo: Colors.cherryRed, colorThree: Colors.cherryRedTwo)
}
I have tried to hide status bar in Tab 4 by this method
1.change View controller-based status bar appearance to YES
2.put
setNeedsStatusBarAppearanceUpdate()
in viewdidload
3.put
override var prefersStatusBarHidden: Bool {
return true
}
in viewdidappear but still not work background of status bar is not hidding and the status background color still change according to the of tab 1-3.
it have one method that work by using this code
UIApplication.shared.isStatusBarHidden = true
and put it in every view controller
but it have warning like this
Setter for 'isStatusBarHidden' was deprecated in iOS 9.0: Use -[UIViewController prefersStatusBarHidden]
I want to know the correct way to change color of the status bar in UITab Thank you.
Ok, if I understand what you want correctly, you want to make your tab 4 to have a clear status bar, here's what you can try if your main view in tab 4, has subviews. Once you change your main view color, the status bar color changes also :
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(true)
if let lastTab = tabBarController?.children[3] {
lastTab.view.backgroundColor = UIColor.white // status bar will be clear
}
}
I am presenting a modal controller which is a UIImagePickerController.
I am trying to change the UIImagePickerController navigation bars' tint colour.
Prior to iOS13 this worked fine;
imagePickerController.navigationBar.tintColor = .red
I have also tried;
imagePickerController.navigationController?.navigationBar.tintColor = .red
but still no joy.
What can I try next?
This was resolved with rmaddy's solution in the comments.
in AppDelegate implement;
func configureGlobalUI() {
UINavigationBar.appearance().tintColor = .red
}
then call in didFinishLaunchingWithOptions
This works as I require the tintColor on all navigationBar appearances.
You can just make UIView the size of the Navigation Bar and put it under navigation bar and make navigation bars color alpha=0.
I hope this helped. :)
I am setting both the navigation bar and the search bar to a custom UIColor (which I call categoryColor in my code). When I do that, I still see an upper grayish line between nav bar and search bar. I have already set the searchBar border color to be the same as the others, but that gray line still exists. Does anyone know how to get rid of it?
Here is my code:
override func viewWillAppear(_ animated: Bool) {
//defining the color that will be used for all the items
let categoryColor = UIColor(hexString: selectCategory?.categoryColorHex ?? UIColor.randomFlat.hexValue())
//changing navigation bar tint color
navigationController?.navigationBar.barTintColor = categoryColor
//changing searchbar tint color
searchBar.barTintColor = categoryColor
//change searchBar border's color
searchBar.layer.borderColor = categoryColor?.cgColor
searchBar.layer.borderWidth = 3
//changing title that appears at the top, after list is loaded
title = selectCategory?.listName ?? "Todoey"
}
Here is a picture of what I see when I run the simulation:
The better way for implementing search bar with nav controller would be to use searchController inside a navigationController so the searchController will have the same background as navigationController. Here’s a great tutorial about that: https://m.youtube.com/watch?v=h7caxpp3Xps
Edit:
Also if you already implemented search capabilities you can do that with searchController too. Just set navigationController.searchConroller.searchBar.delegate for class that’s responsible for handling delegate methods
So, I'm trying to make this:
i tried using UIView in back of Status bar and set the color to orange, but when running, The UIView displayed right under the status bar, so it's still White
i'm trying many solution in the internet but none of them work. Yes it works but when i move to other view controller and back again, The color dissapeared. What should I do? i'm using swift
UIApplication.shared.statusBarStyle = .lightContent
UINavigationBar.appearance().clipsToBounds = true
let statusBar: UIView = UIApplication.shared.value(forKey: "statusBar") as! UIView
statusBar.backgroundColor = UIColor.orange
Try using this code in your appDelegate's method application didFinishLaunchingWithOptions
I've found a post on how to change the tint color of the tab bar button, but it assumes you are using a tab bar controller. I tried any way and did not make a difference. I am using a regular UIView and dragged a Tab Bar control on there. How do I change the button tint color in this scenario? The storyboard and code suggestions are not making a change. I tried to add these into my viewDidLoad ever, but neither had an effect:
self.view.tintColor = UIColor.orangeColor()
self.tabBarController?.tabBar.tintColor = UIColor.orangeColor()
I was able to change the nav bar buttons tints via the storyboard no problem, but the tab bar isn't having any effect. I am trying to match the changes I did to the nav bar:
If you are using a Tab Bar Controller, this will work for the tab bar background color:
tabBarController?.tabBar.barTintColor = UIColor.whiteColor()
And this for the color of the items within the tab bar:
tabBarController?.tabBar.tintColor = UIColor.blackColor()
If you are not using a Tab Bar Controller, and you just dragged a tab bar into your view controller: Control drag from the tab bar in your storyboard to your view controller's swift file to create a new referencing outlet. It should something like this if you're unfamiliar:
#IBOutlet weak var myTabBar: UITabBar!
Then use that same lines of code above just replacing a few things:
myTabBar.barTintColor = UIColor.whiteColor()
myTabBar.tintColor = UIColor.blackColor()