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`
Related
How is it possible to customize the navigation bar like in the AppStore app?
I already tried to set the following (it is a subclass of UINavigationController):
self.navigationBar.setBackgroundImage(UIImage.with(color: UIColor.red), for: .default)
self.navigationBar.shadowImage = UIImage()
self.navigationBar.isTranslucent = true
self.view.backgroundColor = .blue
Then the large navigationBar is blue and the small/collapsed navigationBar is red. But what I have to adjust that I get a translucent navigationBar when the navigationBar is collapsed?
[
I have the nav bar transparent with only the bar button being displayed in my app. In my storyboard I have no title so that the nav bar looks like nothing is there, but when I run the simulator, the text that I deleted is in the nav bar.
This is what i've found to solve problem:
What the nav bar should look like without the transparency
What the nav bar looks like in the simulator
My code for making the bar transparent:
//Makes navigation bar translucent
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
self.navigationController?.navigationBar.shadowImage = UIImage()
self.navigationController?.navigationBar.isTranslucent = true
In your code, inside view will appear method
use this code
self.title = "" // or whatever text you have
In your app delegate, did finish launching with option method:
UINavigationBar.appearance().barTintColor = .white
UINavigationBar.appearance().isTranslucent = false
UINavigationBar.appearance().titleTextAttributes =
[NSForegroundColorAttributeName: UIColor.black] // shouldn't be needed, but if you want something
UINavigationBar.appearance().tintColor = .blue
From your storybord remove any changes done by you. It can be done from code, also since it needs to be consistent in the app. Try to handle status bar and navigation bar from code itself.
I am having view controllers
And I am showing like this
Let assume 1,2,3 are the view controllers.
I navigate like this
1->2->3
When I come back
3->2->1
then from 1 the navigation bar button item cancel of UIImagePicker doesn't show. If I don't go with this sequence (1->2->3
) It shows perfectly.
Please let me know what could be the issue.
I am using opaque navigation bar.
And the navigation bar tint and bar tint color I am updating like this in the appdelegate class
func setNavigationAppearance(tintColor : UIColor, barTintColor : UIColor?) {
let navigationBarAppearace = appDelegateObj.navigationController!.navigationBar
navigationBarAppearace.tintColor = tintColor
navigationBarAppearace.barTintColor = tintColor
navigationBarAppearace.translucent = false
//navigationBarAppearace.
//Settign the Custome Font and TextColor
if let font = UIFont(name: FontCustom.Regular, size: 17) {
UINavigationBar.appearance().titleTextAttributes = [NSFontAttributeName: font ,NSForegroundColorAttributeName : tintColor]
}
}
And adding the background image to the navigation bar like this
if let myImage = UIImage(named: AppImagesName.PatternRed) {
UINavigationBar.appearance().setBackgroundImage(myImage, forBarMetrics: .Default)
}
I recently migrated from Swift 2 to Swift 3 and I'm stuck on one part. In my AppDelegate, I'd set up the default settings for the UINavigationBar as coded below. The challenge I'm having is that the setBackgroundImage is no longer recognized in Swift 3 and I can't find an alternative.
Has anyone had the same issue happen and been able to resolve it?
let turquoiseBackgroundImage:UIImage = UIImage(named: "navigationBarTurqoise")!
**// TODO Below is not working with Swift 3
UINavigationBar.appearance().setBackgroundImage(turquoiseBackgroundImage, forBarPosition: .Default)**
// Set up Back button to be white in Navigation bar
UINavigationBar.appearance().barStyle = UIBarStyle.default
UINavigationBar.appearance().tintColor = UIColor.white
// Font Name and Size of Title in Navigation Bar
if let font = UIFont(name: "TitilliumWeb-Light", size: 20) {
UINavigationBar.appearance().titleTextAttributes = [NSFontAttributeName : font, NSForegroundColorAttributeName : UIColor.white]
}
// Remove hairline between navigation bar and anything below such as search bar
UINavigationBar.appearance().shadowImage = UIImage()
// Set up status bar (battery, time, etc.) to white
UIApplication.shared.statusBarStyle = .lightContent
UINavigationBar.appearance().setBackgroundImage(turquoiseBackgroundImage, forBarPosition: .Default)
rewrite code like this
UINavigationBar.appearance().setBackgroundImage(turquoiseBackgroundImage, for: .default)
How can I change the color of UINavigationController item?
I use Embed In UINavigationController => UIViewController and I have by default "< Back". I want to delete this "Back" text and change the color of item to white.
I did try the next:
override func viewDidLoad() {
super.viewDidLoad()
UINavigationBar.appearance().tintColor = UIColor.whiteColor()
}
inside of the UIViewController inside of which this item appears, but it doesn't help me
Use self.navigationController?.navigationBar.barTintColor to change the color
self.navigationController?.navigationBar.barTintColor = UIColor.whiteColor()
self.navigationController?.navigationBar.tintColor = UIColor.whiteColor()
You can change navigation bar color with following code.
self.navigationController.navigationBar.barTintColor = UIColor.greenColor()
And change Navigation bar text.
self.navigationController.navigationBar.titleTextAttributes = [UITextAttributeTextColor: UIColor.whiteColor()]
Edited
To change Text color of bar button
UIBarButtonItem.appearance().setTitleTextAttributes([UITextAttributeTextColor: UIColor.whiteColor()], forState: UIControlState.Normal)