我像往常一样将 UIImageView 添加到 UIViewController 的 UIView 中,图像视图的框架与self.view
确保图像将覆盖整个视图相同。但是,状态栏和 imageView 之间大约有 20 像素的填充,我似乎无法摆脱。
我试过 NSLogging 不同的帧,并收到以下结果:
NSLog(@"ImageView => %@", NSStringFromCGRect([imageView frame]));
NSLog(@"self.view => %@", NSStringFromCGRect(self.view.frame));
NSLog(@"Screen Bounds => %@", NSStringFromCGRect([[UIScreen mainScreen] bounds]));
NSLog(@"App window => %@", NSStringFromCGRect([[[[UIApplication sharedApplication] delegate] window] frame]));
[LaunchViewController.m: line 26] ImageView => {{0, 0}, {320, 548}}
[LaunchViewController.m: line 27] self.view => {{0, 0}, {320, 548}}
[LaunchViewController.m: line 28] Screen Bounds => {{0, 0}, {320, 568}}
[LaunchViewController.m: line 29] App window => {{0, 0}, {320, 568}}
结果表明,图像视图实际上应该在self.view
其自身和状态栏之间完全没有填充覆盖。
UIViewController 是 UINavigationController 的根视图控制器,我已将导航栏设置为隐藏。我认为这可能会导致问题,但是,在删除 UINavigationController 并将其替换为 UIViewController 之后,填充仍然存在。
有没有人对删除填充有任何建议/以前遇到过这个问题并有修复?
这是一张显示正在发生的事情的图像 - 绿色区域是 UIView ( self.view
),橙色区域是 UIImageView。
[self.navigationController setNavigationBarHidden:YES];
[self.view setBackgroundColor:[UIColor greenColor]];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.view.frame];
[imageView setImage:[UIImage imageNamed:@"Orange-568h@2x.png"]];
[self.view addSubview:imageView];