iOS Play

iOS 不同系统版本的 rightBarButtonItem 显

2018-09-07  本文已影响5人  tianheng
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setTitle:@"测试" forState:UIControlStateNormal];
[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
button.titleLabel.font = [UIFont systemFontOfSize:17.];
[button addTarget:self action:@selector(rightTitleButtonClick:) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];

模拟器测试:
iPhone X(11.4):正常显示
iPhone 6s(9.3):不显示

建议解决办法:

1.
button.frame = CGRectMake(0, 0, 64., 20.);
2.
[button sizeToFit];
上一篇下一篇

猜你喜欢

热点阅读