Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 383 Vote(s) - 3.38 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Change color of Back button in navigation bar

#11
Swift


override func viewDidLoad() {
super.viewDidLoad()

self.navigationController?.navigationBar.tintColor = UIColor.white
}
Reply

#12
You should add this line

self.navigationController?.navigationBar.topItem?.backBarButtonItem?.tintColor = .black
Reply

#13
You can change the global tint color in your storyboard by clicking on an empty space on the board and select in the right toolbar "Show the file inspector", and you will see in the bottom of the toolbar the "Global Tint" option.

[![Global Tint option in storyboard][2]][2]

[1]:

[2]:
Reply

#14
It will be solved with this line in -(void)viewDidLoad:



self.navigationItem.backBarButtonItem.tintColor = UIColor.whiteColor;
Reply

#15
All the answers setting `UINavigationBar.appearance().tintColor` conflict with Apple's documentation in `UIAppearance.h`.

> Note for iOS7: On iOS7 the `tintColor` property has moved to `UIView`, and now has special inherited behavior described in `UIView.h`.
This inherited behavior can conflict with the appearance proxy, and therefore `tintColor` is now disallowed with the appearance proxy.

In Xcode, you need to command-click on each property you want to use with appearance proxy to inspect the header file and make sure the property is annotated with `UI_APPEARANCE_SELECTOR`.


So the correct way to color the navigation bar purple and the title and buttons white throughout the app via the appearance proxy is:

UINavigationBar.appearance().isTranslucent = false
UINavigationBar.appearance().barTintColor = .purple
UINavigationBar.appearance().titleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.white]
UIBarButtonItem.appearance().tintColor = .white

Note that `UIBarButtonItem` is not a subclass of `UIView` but rather `NSObject`. So its `tintColor` property is not the inherited `tintColor` from `UIView`.

Unfortunately, `UIBarButtonItem.tintColor` is not annotated with `UI_APPEARANCE_SELECTOR` – but that seems to me a documentation bug. The response from Apple Engineering in [this radar](

[To see links please register here]

) states it is supported.
Reply

#16
In Swift 4, you can take care of this issue using:

let navStyles = UINavigationBar.appearance()
// This will set the color of the text for the back buttons.
navStyles.tintColor = .white
// This will set the background color for navBar
navStyles.barTintColor = .black

Reply

#17
If you already have the back button in your "Settings" view controller and you want to change the back button color on the "Payment Information" view controller to something else, you can do it inside "Settings" view controller's prepare for segue like this:

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "YourPaymentInformationSegue"
{
//Make the back button for "Payment Information" gray:
self.navigationItem.backBarButtonItem?.tintColor = UIColor.gray
}
}
Reply

#18
Not sure why nobody has mentioned this...but I was doing exactly what you were doing in my **`viewDidLoad`**...and it wasn't working. Then I placed my code into **`viewWillAppear`** and it all worked.

The above solution is to change a *single* barbuttonItem. If you want to change the color for *every* navigationBar in your code then follow [this answer](

[To see links please register here]

).

Basically changing onto the class itself using `appearance()` is like making a global change on all instances of that view in your app. For more see [here](

[To see links please register here]

)

Reply

#19
In **Swift3**, To set the Back button to `red`.

self.navigationController?.navigationBar.tintColor = UIColor.red
Reply

#20
Use this code in `AppDelegate` class, inside of `didFinishLaunchingWithOptions`.

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

UINavigationBar.appearance().tintColor = .white

}
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through