iOS 9:UINavigationBar 景观中不需要的边距
iOS 9: Unwanted margin in UINavigationBar landscape
有一个自定义的导航栏,它在 iOS 9 之前一直很好用。
横向模式出现奇怪的边距。
标准代码用于创建此布局。
- (UIBarButtonItem*)leftMenuButton {
UIButton *menuBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[menuBtn setImage:[UIImage imageNamed:@"menu_button.png"] forState:UIControlStateNormal];
UIView *backArea = [[UIView alloc] initWithFrame:CGRectMake(0, 0, menuBtn.frame.size.width, menuBtn.frame.size.height)];
[backArea addSubview:menuBtn];
//layer border are enabled just for issue visualization
backArea.layer.borderColor = [UIColor redColor].CGColor;
backArea.layer.borderWidth = 1;
menuBtn.layer.borderColor = [UIColor greenColor].CGColor;
menuBtn.layer.borderWidth = 2;
UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithCustomView:backArea];
return backItem;
}
我也刚刚偶然发现了这个。当设备处于横向模式时,iOS9 中的导航栏内容未对齐。看起来栏内容的位置使其适合 Compact
指标,即使该栏仍然使用 Default
指标(例如,当在 UINavigationController
之外使用时)。看起来条形图以某种方式耦合了屏幕方向。真是一团糟。
编辑: 打开雷达 #23027275。
有一个自定义的导航栏,它在 iOS 9 之前一直很好用。 横向模式出现奇怪的边距。
标准代码用于创建此布局。
- (UIBarButtonItem*)leftMenuButton {
UIButton *menuBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[menuBtn setImage:[UIImage imageNamed:@"menu_button.png"] forState:UIControlStateNormal];
UIView *backArea = [[UIView alloc] initWithFrame:CGRectMake(0, 0, menuBtn.frame.size.width, menuBtn.frame.size.height)];
[backArea addSubview:menuBtn];
//layer border are enabled just for issue visualization
backArea.layer.borderColor = [UIColor redColor].CGColor;
backArea.layer.borderWidth = 1;
menuBtn.layer.borderColor = [UIColor greenColor].CGColor;
menuBtn.layer.borderWidth = 2;
UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithCustomView:backArea];
return backItem;
}
我也刚刚偶然发现了这个。当设备处于横向模式时,iOS9 中的导航栏内容未对齐。看起来栏内容的位置使其适合 Compact
指标,即使该栏仍然使用 Default
指标(例如,当在 UINavigationController
之外使用时)。看起来条形图以某种方式耦合了屏幕方向。真是一团糟。
编辑: 打开雷达 #23027275。