Is it still possible to customize the navigation bar on ScrollViewDidScroll now?
For example:
Change it using:
self.navigationController?.navigationBar.isTranslucent = False
And remove:
self.navigationController?.navigationBar.setBackgroundImage...
self.navigationController?.navigationBar.shadowImage = UIImage()
Then modify the barTintColor when user scrolls.
Related
I make this screen with collection view with using supplementary HeaderView. I want to make this HeaderView to the status bar. I make clear color to status bar but it is not working. Please help me with it.
I think you need to make the next, delete this view and put this image in the back of the navigation bar, the next is putting navigation bar transparent and the tint color in white like this :
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
self.navigationController?.navigationBar.shadowImage = UIImage()
self.navigationController?.navigationBar.isTranslucent = true
self.navigationController?.view.backgroundColor = .clear
self.navigationController?.navigationBar.tintColor = UIColor.white
You could try to get the contents of the collection view started earlier.
collectionView.contentInset.top = -14
So, first of all in your info.plst tap "+" button and this line.
Than in your UIViewController add this method.
override var prefersStatusBarHidden: Bool {
return true
}
Status bar will be hidden only in this viewController.
I have a navigation bar created by the nav controller for my view, these are loaded via a container side menu.
When i click an item, it loads the nav controller and view, but the nav bar background drops out showing a blank background colour on the status bar.
Any idea how I can diagnose this issue? I have included some view debugger screenshots to best illustrate
UINavigationBar.appearance().tintColor = UIColor.white
UINavigationBar.appearance().barTintColor = UIColor().appThemeColour()
UINavigationBar.appearance().isTranslucent = false
UINavigationBar.appearance().shadowImage = UIImage()
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName : UIColor.white]
UIApplication.shared.statusBarStyle = .lightContent
Well you are missing one thing here and thats setBackgroundImage of UINavigationBar.
UINavigationBar.appearance().tintColor = UIColor.white
UINavigationBar.appearance().barTintColor = UIColor().appThemeColour()
UINavigationBar.appearance().isTranslucent = false
UINavigationBar.appearance().shadowImage = UIImage()
UINavigationBar.appearance().setBackgroundImage(UIImage(), for: .default)
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName : UIColor.white]
UIApplication.shared.statusBarStyle = .lightContent
*Note this is the solution for Sidemenu Library named "https://github.com/jonkykong/SideMenu/"
Change status bar end alpha property to 0
Please find code below.
#objcMembers
open class SideMenuPresentationStyle: InitializableClass {
/// Background color behind the views and status bar color
open var backgroundColor: UIColor = .white`
Hi I want to implement a transcluent NavigationBar so underlying objects are visible.
It should look like here:
This view is a custom view wich uses alpha value to achieve the translucency behavior.
I tried this to implement my custom NavigationBar like this:
UINavigationBar.appearance().barTintColor = .white
UINavigationBar.appearance().tintColor = UIColor(netHex: CxtColor.black.rawValue)
UINavigationBar.appearance().shadowImage = UIImage()
UINavigationBar.appearance().isTranslucent = true
UINavigationBar.appearance().setBackgroundImage(UIImage(), for: .default)
UINavigationBar.appearance().inputView?.alpha = 0.4
UINavigationBar.appearance().alpha = 0.4
But its not translucent and also the changing of the alpha value has no really effect on the NavigationBar. Its just a white navigationbar.
I don't want to create a full transparent navigationbar.
]you can access navigationBackgroundView
self.navigationController?.navigationBar.isTranslucent = true
let navigationBackgroundView = self.navigationController?.navigationBar.subviews.first
navigationBackgroundView?.alpha = 0.3
I create an app with Swift 3 and Xcode 8.1, I have a view controller with navigation bar, my view shows a line (separator) between the bar and other viewController's content.
I use following code in viewDidLoad:
self.navigationController?.navigationBar.isTranslucent = false
But nothing changed, for more details here's a screenshot:
What I can do to solve that?
Try:
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
self.navigationController?.navigationBar.shadowImage = UIImage()
And if you want to apply this effect to the whole app (so that you don't need to write this code for every navigation controller) you can use:
UINavigationBar.appearance().setBackgroundImage(UIImage(), forBarPosition: UIBarPosition.Any, barMetrics: UIBarMetrics.Default)
UINavigationBar.appearance().shadowImage = UIImage()
I have a two TableViewControllers with Embedded Navigation Controllers. ViewController-1 shows the hairline/shadow under the nav bar and ViewController-2 doesn't show it when I navigate to it. Navigation is done using the Push Segue
To hide the navigation bar in ViewController-2 I adding the following lines in ViewWillAppear the following:
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default)
self.navigationController?.navigationBar.shadowImage = UIImage()
self.navigationController?.navigationBar.translucent = false
When I use the back button to go back to ViewController-1 the Hairline disappears there too but I do not want it to. Is there anyway to ensure that the hairline doesn't hide in ViewController-1?
I have tried :
self.navigationController?.navigationBar.barStyle = UIBarStyle.Black
and
self.navigationController?.navigationBar.backgroundColor = UIColor.whiteColor()
but without much success.
In the viewWillDisappear (or maybe the viewDidDisappear) method of ViewController-2, add code to undo the changes made in viewWillAppear.
self.navigationController?.navigationBar.setBackgroundImage(nil, forBarMetrics: UIBarMetrics.Default)
self.navigationController?.navigationBar.shadowImage = nil
self.navigationController?.navigationBar.translucent = true