In React-native, Как изменить стили NavigatorIOS - программирование
Подтвердить что ты не робот

In React-native, Как изменить стили NavigatorIOS

in response-native, как изменить стили NavigatorIOS, например backgroundColor? спасибо!

var speedNews = React.createClass({
  render: function() {
    return (
      <NavigatorIOS style={styles.container} 
      initialRoute={{ 
        title: 'SpeedNews',
        component: ViewList
      }}/>
    );
  }
});

var styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor : 'red', // it do nothing
    color : '#ffffff' // it do nothing
  }
});
4b9b3361

Ответ 1

Насколько я знаю, вы можете изменить только следующие свойства:

  • barTintColor: цвет фона панели.
  • titleTextColor: цвет шрифта.
  • tintColor: цвет кнопок.
<NavigatorIOS
  barTintColor='#000'
  titleTextColor='#fff'
  tintColor='#fff'
  initialRoute={{
    title: 'SpeedNews',
    component: ViewList
  }} />

Ответ 2

Если ваш стиль навигации согласован во всем приложении, самым простым способом является его появление в делетете приложений.

приведенный ниже пример устанавливает цвет фона, цвет шрифта и свойства шрифта заголовка.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

  [[UINavigationBar appearance] setBarTintColor:[UIColor primaryColor]];
  [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];

  [[UINavigationBar appearance] setTitleTextAttributes:@{
    NSFontAttributeName : [UIFont fontWithName:@"AppleSDGothicNeo-SemiBold" size:22.0],
    NSForegroundColorAttributeName : [UIColor whiteColor]
  }];



  return YES;
}