Change color of Back button in navigation bar
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
To customize the appearance of your application's navigation bar, changing the color of the back button is an important aspect for both aesthetic considerations and user experience. The back button, typically found in mobile navigation bars, provides users with an intuitive way to return to the previous view, and its visibility can greatly affect usability.
Customizing the Back Button Color in iOS
In iOS development, the navigation bar is often used to navigate through hierarchical content. The back button, by default, inherits its color from the navigation bar's tint color or the global tint of the app. However, situations may arise where the back button needs a specific color suitable for the design.
Using UINavigationBarAppearance
Modern iOS development, starting from iOS 13, utilizes the UINavigationBarAppearance to manage navigation bar styles more efficiently.
Older iOS Versions
If you are maintaining an application for older iOS versions, you can directly set the tint color of the navigation bar which affects all bar button items, including the back button:
Customizing the Back Button Color in Android
For Android developers working with the ActionBar or Toolbar, customizing the color of the back button — often referred to as the "up" button — can be crucial for adaptation to different themes.
Using Themes and Styles
You can define a style in your styles.xml file for your toolbar. Within this file, you can set the color of the navigation back button:
Programmatically Setting the Back Button Color
The back button's color can also be set programmatically using the Toolbar's navigation icon:
Considerations
Aesthetic Consistency
Maintaining visual consistency across your app’s UI ensures your users have a cohesive experience. Thus, always consider how the back button's color complements the rest of your app’s color scheme.
Accessibility
Ensure that there is enough contrast between your back button and its background to make it easily distinguishable, thereby maintaining accessibility standards. Tools like WCAG contrast guidelines help evaluate sufficient contrast levels.
Testing Across Devices
Different devices might exhibit slight variations in color rendering; therefore, testing your app across multiple devices is crucial to ensuring the back button appears as intended.
Summary Table
Here is a quick summary of methods for changing the back button color:
| Platform | Method | Code Example |
| iOS (13+) | UINavigationBarAppearance | let appearance = UINavigationBarAppearance()
appearance.backButtonAppearance.normal.titleTextAttributes = [.foregroundColor: UIColor.white] |
| iOS (<13) | tintColor property | navigationController?.navigationBar.tintColor = UIColor.white |
| Android XML | Themes and Styles | <item name="colorControlNormal">@color/colorAccent</item> |
| Android Code | Programmatically using Toolbar | Drawable upArrow = ContextCompat.getDrawable(this, R.drawable.ic_arrow_back);
upArrow.setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_ATOP); |
By customizing the color of the back button, you can more closely align your app's design with your brand while also enhancing the user experience.

