我正在viewWillAppear中的UIViewController中以编程方式创建导航栏。在我将iOS更新到iOS 11之后,高度保持不变并且现在没有变化。我在Stack上检查了与它相关的所有答案,但这些答案是针对UIView而不是针对UIViewController。
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:YES];
// Do any additional setup after loading the view.
UINavigationBar *navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0,0, self.view.frame.size.width, 50)];
navBar.barTintColor = [UIColor colorWithRed:160.0/225 green:72.0/225 blue:178.0/225 alpha:1.0];
[self.view addSubview:navBar];
}
感谢您的帮助!