我正在使用它来创建导航栏,但在 iPhoneX 中,由于安全区域视图布局,它会中断
navbar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, [UIApplication sharedApplication].keyWindow.rootViewController.view.frame.size.width, 50)];
navItem = [[UINavigationItem alloc] initWithTitle:@"Title"];
cancelBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(onTapCancel:)];
navItem.leftBarButtonItem = cancelBtn;
[navbar setItems:@[navItem]];
我们如何在 Objective-C 中做到这一点来支持 iPhoneX?