React-native-navigation: iOS back button text

Created on 26 Apr 2017  路  9Comments  路  Source: wix/react-native-navigation

Is it possible to either change the font of the back button text, or hide the text and show just the icon? Setting navBarTextFontFamily changes the font of the title, but not the back button text.


Environment

  • React Native Navigation version: 1.1.21
  • React Native version: 0.43.4
  • Platform(s) (iOS, Android, or both?): iOS

Most helpful comment

set backButtonTitle to ''

All 9 comments

I know it's possible to hide the back button text natively. See http://justabeech.com/2014/02/24/empty-back-button-on-ios7/

set backButtonTitle to ''

You can take advantage of UIAppearance to change font of UIBarButtonItem in RCCNavigationController for iOS. Just put code below in didFinishLaunchingWithOptions.
[[UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[RCCNavigationController class]]] setTitleTextAttributes:@{NSFontAttributeName: [UIFont fontWithName:@"family" size:15]} forState:UIControlStateNormal];

Awesome! This is exactly what I was looking for.

@cskaynar I'm just now getting the chance to try implementing this. I'm getting an error: Unknown receiver 'RCCNavigationController'. What do I need to include in my AppDelegate to get this to work?

Nevermind, I figured it out. You need to add this line:

#import "RCCNavigationController"

@jtibbertsma Hi! Did you have a way to push to native view controller?Thanks !

@zhaiyjgithub You mean have different back button fonts on screen by screen basis? No, I set it globally as per cskaynar's post

@guyca @yogevbd
hey guys.
This is should be in the fontFamily option, inside backButton(iOS specific options) object.
am I right?

Was this page helpful?
0 / 5 - 0 ratings