React-Native-Navigation图标对齐

问题描述 投票:0回答:1

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

徽标在导航栏中设置如下:

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

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

但是,在iOS上我得到this

我搜索了文档,似乎无法找到任何能够像iOS一样将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个回答
0
投票

在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中做类似的事情。希望这会有所帮助。

© www.soinside.com 2019 - 2024. All rights reserved.