Ios Objective-C应用程序中的iPhone X安全布局区域
我正在开发一个用Objectice-c编写的应用程序,没有故事板和自动布局 我在iPhone X中面临问题(请参见下文) ---iPhone X--- ---iPhone SE--- 下面是我写的粗体标题代码Ios Objective-C应用程序中的iPhone X安全布局区域,ios,objective-c,iphone,Ios,Objective C,Iphone,我正在开发一个用Objectice-c编写的应用程序,没有故事板和自动布局 我在iPhone X中面临问题(请参见下文) ---iPhone X--- ---iPhone SE--- 下面是我写的粗体标题代码 _topHeaderLabel = [[UILabel alloc] initWithFrame:CGRectMake(30, 20, CGRectGetWidth(self.view.frame)-60, CGRectGetHeight(self.view.frame)* 0.2)]
_topHeaderLabel = [[UILabel alloc] initWithFrame:CGRectMake(30, 20, CGRectGetWidth(self.view.frame)-60, CGRectGetHeight(self.view.frame)* 0.2)];
_topHeaderLabel.text = @"Please select bank account you want to link";
_topHeaderLabel.textAlignment = NSTextAlignmentCenter;
我可以看到UI在所有iPhone设备中都是完美的,除了iPhone X。请告诉我我在这里做错了什么。我无法应用自动布局,因为应用程序已编写
任何想法或建议都很好。你的身高一定有问题
_topHeaderLabel.sizeToFit()
另外,如果检测设备为X->self.view.safeAreaInsets.top,请检查此项
在IPhoneX中试试这个,IPhoneX的顶部插图是44,但你设置为20,如果你使用导航条,它将是88
UILabel*topHeaderLabel = [[UILabel alloc] initWithFrame:CGRectMake(30,self.view.safeAreaInsets.top, CGRectGetWidth(self.view.frame)-60, CGRectGetHeight(self.view.frame)* 0.2)];
你是否通过safeAreaInsets
插入了所有内容?@Brandon不,我没有。只知道在文本上添加黑色不会阻止我们找到下面的内容。如果是敏感信息,请将其从帖子中删除(并要求imgur删除该图像):