1
长话短说iOS10左侧,右侧按钮,自定义标签没有问题,iOS11没有显示。我在其他地方看过,我需要为按钮添加约束条件,但这没有帮助。在viewDidLoad()
中调用的代码。UIBarButtonItem不能在ios11中工作
self.connectionButton = [[UIButton alloc] initWithFrame:CGRectMake(0.0,0.0,74.0,29.0)];
[self.connectionButton.widthAnchor constraintEqualToConstant:74].active = YES;
[self.connectionButton.heightAnchor constraintEqualToConstant:29].active = YES;
self.connectionButton.backgroundColor = [UIColor yellowColor];
UIBarButtonItem *buttonItem = [[UIBarButtonItem alloc] initWithCustomView:self.connectionButton];
self.navigationItem.rightBarButtonItem = buttonItem;
外观:
[[UINavigationBar appearance] setTranslucent:YES];
[[UINavigationBar appearance] setShadowImage:[UIImage new]];
[[UINavigationBar appearance] setBackgroundImage:[UIImage new] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setBackgroundColor:[UIColor clearColor]];
当我检查在运行时框架是正确的(0,0,74,29)。虽然没有按钮显示在栏中。
XCode 9 beta 8,不能在任何设备或模拟器上工作。
请分享您的完整NavBar设置(外观配置等)。你在哪种方法设置rightBarButtonItem? –
已编辑。 Afaik没什么特别的,默认在故事板上用于根控制器。 – Tom
我也有同样的问题,在ios11 barbuton时间iboutlet不工作...它显示不是密钥值编码兼容的关键,任何帮助 – Tech