I have a child navigation view controller with a collectionView embedded in it. When I scroll it, the navigation bar appears to be dimmed a bit.
It looks like this:
Does anyone know how to remove this behavior?
I was setting my navigation bar appearance globally like that:
let appearance = UINavigationBarAppearance()
appearance.shadowImage = UIImage()
...
UINavigationBar.appearance().standardAppearance = appearance
But I finally managed to find the fix. You just have to add this:
appearance.backgroundEffect = nil
and the problem goes away.
Related
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
Is it possible to use the UISearchController without the SearchBar being displayed in the Navigation Controller? I basically want the SearchBar to stay on the screen and display the TableView beneath it:
What I was trying to do is this:
I've created a UITableViewController on the storyboard and linked it to the custom NPTableViewController class. Then I did this:
let resultsTable = storyboard!.instantiateViewController(withIdentifier: "LocationSearch") as! NPTableViewController
searchController = UISearchController(searchResultsController: resultsTable)
searchController?.searchResultsUpdater = resultsTable
let searchBar = searchController!.searchBar
searchBar.sizeToFit()
searchBar.placeholder = "Search for places"
searchBar.frame.origin.y = 100.0
self.view.addSubview(searchBar)
Now when I run it, the searchBar is displayed but when I click on it the background dims, the searchBar disappears my resultsTable is also not displayed.
The solution I came up with is actually very simple. Instead of using UISearchController, I used a normal UISeachBar and UITableView. Since UISearchController doesn't do so much to help you, the work is pretty much the same if I kind of build my own SearchController.
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
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()