iOS 9:UINavigationBar景观中不需要的边距
有一个定制的导航栏,它在iOS 9之前工作得非常好。 在横向模式下出现奇怪的边距 标准代码用于创建此布局iOS 9:UINavigationBar景观中不需要的边距,ios,uinavigationbar,margin,uibarbuttonitem,ios9,Ios,Uinavigationbar,Margin,Uibarbuttonitem,Ios9,有一个定制的导航栏,它在iOS 9之前工作得非常好。 在横向模式下出现奇怪的边距 标准代码用于创建此布局 - (UIBarButtonItem*)leftMenuButton { UIButton *menuBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [menuBtn setImage:[UIImage imageNamed:@"menu_button.png"] forState:UIControlStateNorm
- (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;
}
我也刚刚偶然发现了这一点。当设备处于横向模式时,iOS 9中的导航栏内容未对齐。它看起来像是定位了条内容,使其适合
Compact
度量,即使条仍然使用默认
度量(例如,在UINavigationController
之外使用时)。看起来这些条是以某种方式耦合在屏幕方向上的。真是一团糟
编辑:打开的雷达#23027275。设置菜单约束。这是一个非常古老的项目,它不使用自动布局