繁体   English   中英

存在导航栏和标签栏控制器时的UIView框架

[英]UIView frame when navigation bar and tab bar controller exist

我在loadView中以编程方式创建了一个UIView。 该应用程序有一个UITabBarController和UINavigationController。

当标签栏和导航栏都存在时,如何创建自动调整大小的视图?

我目前解决这个问题的方法是计算导航和标签栏控制器的高度,并从主屏幕的高度中减去它们:

float navObjectsHeight = self.tabBarController.tabBar.frame.size.height 
    + self.navigationController.navigationBar.frame.size.height;

CGRect mainFrame = CGRectMake(0, 0, screenFrame.size.width, 
  screenFrame.size.height - navObjectsHeight);

UIView *contentWrapper = [[UIView alloc] initWithFrame:mainFrame];

UIView有一个处理这种情况的财产。 在以编程方式创建它时,要使用的代码是:

UIView *aView = [[UIView alloc] init];
aView.autoresizingMask = UIViewAutoresizingFlexibleHeight;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM