【问题标题】:React-Native-Navigation Icon AlignmentReact-Native-Navigation 图标对齐
【发布时间】:2018-05-16 16:21:21
【问题描述】:

我一直在我当前的 react native 应用程序中使用 react-native-navigation,但我遇到了问题。我的应用程序上有一个导航栏,左按钮作为抽屉菜单的切换,右按钮是链接到我们公司网站的徽标。

导航栏中的标志设置如下:

icon: require('../logos/BB-Icon.png')

在 android 上查看应用程序时,我得到以下结果 as seen here.

但是,在 iOS 上,我得到 this

我搜索了文档,似乎找不到任何可以像 Android 一样在 iOS 中将导航栏居中的内容。

环境:

  • React Native Navigation 版本:1.1.444
  • React Native 版本:0.52.0
  • 设备信息:Android:运行 Android 8.0.0 的三星 Galaxy S9 // iOS:运行 iOS 11.3 的 iPhone X 模拟器

【问题讨论】:

    标签: react-native react-native-navigation wix-react-native-navigation


    【解决方案1】:

    在 2.17 中,您可以像这样修改lib/ios/RNNUIBarButtonItem.m

    -(instancetype)init:(NSString*)buttonId withIcon:(UIImage*)iconImage {
        UIButton* button = [[UIButton alloc] init];
        [button addTarget:self action:@selector(onButtonPressed) forControlEvents:UIControlEventTouchUpInside];
        [button setImage:iconImage forState:UIControlStateNormal];
        [button setFrame:CGRectMake(0, 0, iconImage.size.width, iconImage.size.height)];
        self = [super initWithCustomView:button];
        self.buttonId = buttonId;
    // Align left or right here.
        button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
        return self;
    }
    

    我不知道你是否可以在版本 1.x 中做类似的事情。希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-10
      • 2020-07-25
      • 2016-07-23
      • 1970-01-01
      • 1970-01-01
      • 2017-10-24
      相关资源
      最近更新 更多