gpt4 book ai didi

iphone - 通过编程 View 创建避免对 iPhone 屏幕尺寸进行硬编码

转载 作者:行者123 更新时间:2023-12-03 18:27:59 24 4
gpt4 key购买 nike

我正在查找如何以编程方式创建 View ,并找到了以下示例代码:

self.view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];

这很好用,但我不喜欢它硬编码屏幕的大小。有没有办法查看屏幕尺寸?有人提出的一个重要观点是,如果应用程序在通话过程中运行,那么屏幕会因为绿色的“返回通话”栏而稍微小一些。

最佳答案

Is there a way to look up the size of the screen?

是的:

CGRect screenRect = [[UIScreen mainScreen] applicationFrame];

applicationFrame

This property contains the screen bounds minus the area occupied by the status bar, if it is visible. Using this property is the recommended way to retrieve your application’s initial window size. The rectangle is specified in points.

关于iphone - 通过编程 View 创建避免对 iPhone 屏幕尺寸进行硬编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2530647/

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