gpt4 book ai didi

ios - 当导航栏不透明时 UIViewController View 太低

转载 作者:行者123 更新时间:2023-11-29 03:42:01 31 4
gpt4 key购买 nike

当我将 navigationBarHidden 设置为 NO 时,但我使导航栏半透明,当我使用 initWithFrame: 初始化它时,我会打印该框架>,它是 {{0, 0}, {320, 504}}。该 View 出现在 navigationBar 下方。然后,当我使用 [[self.navigationController navigationBar] setTranslucent:NO] 将导航栏设置为不半透明时,我打印框架的 View ,它是 {{0, 0}, { 320, 504}}。我缩放了 iPhone 模拟器,使其与实际 4 英寸 iPhone 的尺寸相同,这是一个屏幕截图。您可以看到导航栏和我的 View 顶部之间现在有一个巨大的空间,该空间是红色的。是什么造成了空间?两张图片之间的唯一区别是我在第一张图片中注释掉了 [[self.navigationController navigationBar] setTranslucent:NO]

enter image description here

enter image description here

最佳答案

尝试将主视图框架更改为 [UIScreen mainScreen] 边界]

UIView *testView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
testView.backgroundColor = [UIColor blueColor];
[self.view addSubview:testView];

关于ios - 当导航栏不透明时 UIViewController View 太低,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18294553/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com