How to change navigation bar & back button colour iOS 15
These lines are totally pointless:
let navigationBar = UINavigationBar()
navigationBar.tintColor = .white
navigationBar.standardAppearance = appearance
You are creating a navigation bar, configuring it, and throwing it away. That does nothing for your app. Rewrite meaningfully:
let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.titleTextAttributes = [.foregroundColor: UIColor.white]
appearance.backgroundColor = .red
let proxy = UINavigationBar.appearance()
proxy.tintColor = .white
proxy.standardAppearance = appearance
proxy.scrollEdgeAppearance = appearance
How to change color of back button on NavigationView
You can use the accentColor
property on the NavigationView to set the back button color, like in this example:
var body: some View {
NavigationView {
List(1..<13) { item in
NavigationLink(destination: Text("\(item) x 8 = \(item*8)")) {
Text(String(item))
}
}.navigationBarTitle("Table of 8")
}.accentColor(.black) // <- note that it's added here and not on the List like navigationBarTitle()
}
How to change the Back button color in a DetailViewController?
I was able to change it with:
self.navigationController?.navigationBar.tintColor = UIColor.white
Hope this works for you!
Edit:
Once you create the project, you'll see the following in your storyboard:
I changed it to following:
Which gave me the following output:
And following is my code for viewDidLoad()
in DetailViewController:
override func viewDidLoad() {
super.viewDidLoad()
self.navigationController?.navigationBar.tintColor = UIColor.red
// Do any additional setup after loading the view, typically from a nib.
configureView()
}
Hope this makes it clear enough now.
Swift change font and color of back button
If you want to set same color to bar buttons implicitly then in your AppDelegate
, in didfinishlaunchingwithoptions
, write:
UINavigationBar.appearance().tintColor = UIColor.white //your desired color here
Update :
Put this in AppDelegate
,
UIBarButtonItem.appearance().setTitleTextAttributes([NSFontAttributeName: UIFont(name: "Andes Rounded", size: 17)!], forState: .Normal) // your textattributes here
Update 2 :
UIBarButtonItem.appearanceWhenContainedInInstancesOfClasses([UINavigationBar.classForCoder()]).setTitleTextAttributes(["attribute" : "value"], forState: .Normal)
Hope this will help :)
What is the right way to set back button arrow tint in ios 13
The new way of setting the back button color of the appearance (proxy) would be:
let appearance = UINavigationBarAppearance()
// Apply the configuration option of your choice
appearance.configureWithTransparentBackground()
// Create button appearance, with the custom color
let buttonAppearance = UIBarButtonItemAppearance(style: .plain)
buttonAppearance.normal.titleTextAttributes = [.foregroundColor: UIColor.white]
// Apply button appearance
appearance.buttonAppearance = buttonAppearance
// Apply tint to the back arrow "chevron"
UINavigationBar.appearance().tintColor = UIColor.white
// Apply proxy
UINavigationBar.appearance().standardAppearance = appearance
// Perhaps you'd want to set these as well depending on your design:
UINavigationBar.appearance().compactAppearance = appearance
UINavigationBar.appearance().scrollEdgeAppearance = appearance
How to change back button color in nav bar?
Use Below To Change Back Button Color:
navigationController?.navigationBar.tintColor = UIColor.red
To Change Title Color of The Navigation Bar Use:
navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.red]
Change color and back button title of Navigation Bar from Swift 3 code
try
self.navigationController?.navigationBar.tintColor = UIColor.white
How can I change the font and color of the Navigation Bar back button
It's a UIBarButtonItem
so set this property.
init() {
UIBarButtonItem.appearance().tintColor = .red
UIBarButtonItem.appearance().setTitleTextAttributes([NSAttributedString.Key.font: UIFont.systemFont(ofSize: 10)], for: .normal)
}
Or you can use this also,
init() {
let standard = UINavigationBarAppearance()
let button = UIBarButtonItemAppearance(style: .plain)
button.normal.titleTextAttributes = [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 10), NSAttributedString.Key.foregroundColor: UIColor.red]
standard.buttonAppearance = button
}
Related Topics
Storyboard View Elements Greyed Out
Xcode Simulator: How to Remove Older Unneeded Devices
Uitableview Dynamic Cell Heights Only Correct After Some Scrolling
Programmatically Add Centerx/Centery Constraints
Why Does My Programmatically Created Screenshot Look So Bad on iOS 7
Swift 3 - Comparing Date Objects
Move a Node to Finger Using Swift + Spritekit
iOS - How to Play a Video with Transparency
What's a Redirect URI? How Does It Apply to iOS App for Oauth2.0
Use Didselectrowatindexpath or Prepareforsegue Method for Uitableview
Possible to Handle Your Own Http Url Schemes in iOS