UIView框架比iPhone屏幕大

发布于 2024-10-18 02:19:54 字数 387 浏览 2 评论 0原文

我在 XCode 中创建了一个新的基于 iPhone 视图的项目,并查看了生成的 xib,其名称为 myAppViewController.xib。在该 xib 中,生成的视图的框架如下所示: { x = 160, y = 230, w = 320, h = 460 } 该视图应该填充整个屏幕,不包括状态栏。我希望视图的框架看起来像这样:对于旧款 iPhone,{ x = 0, y = 0, w = 240, y = 300 },以及 { x = 0, y = 0, w = 480, h = 600 } 用于视网膜显示。然而,我得到了上面那些奇怪的值。谁能向我解释一下这里发生了什么,它破坏了我其他项目中的一些绘图代码(要绘制的区域基于视图的框架)。

I have made a new iPhone View-based project in XCode, and I have a look at the xib generated, with the name myAppViewController.xib. In that xib, the generated view's frame looks like this: { x = 160, y = 230, w = 320, h = 460 } this view is supposed to fill the entire screen, excluding the status bar. I would expect the view's frame to look like this: { x = 0, y = 0, w = 240, y = 300 } for the older iPhones, and { x = 0, y = 0, w = 480, h = 600 } for the retina display. However, I get those weird values above. Can anyone please explain to me what is happening here, it is ruining some of my drawing code in my other project (the area to draw is based off of the frame of the view).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

っ〆星空下的拥抱 2024-10-25 02:19:54

视网膜显示屏实际上并没有增加视图的点大小。
当苹果推出它时,它区分了像素。视网膜显示屏具有更多像素,但点数相同。
代码中与 UIKit 相关的所有内容通常都以点为单位,因此不需要进行任何更改,100x100 的视图仍将是该大小。

我真的不明白你的问题,但框架值可以通过 bounds 属性和 center 属性修改......所以请检查你是否没有修改这些。

Retina display doesn't actually increase the point size of the view.
When Apple introduced it, it made a difference between points and pixels. Retina display has more pixels, but the same amount of points.
Everything in your code related to UIKit will generally be in points, so no changes are needed there, a view of 100x100 will still be that size.

I don't understand really your question but the frame value can be modified by the bounds property and the center property... so check if you're not modifying those.

陈甜 2024-10-25 02:19:54

框架矩形如下:

CGRectMake(CGFloat x, CGFloat y, CGFloat width, CGFloat height)

屏幕宽度为 320 像素宽 x 480 像素高。状态栏是20px。因此,您想要的矩形是:

CGRectMake(0,0,320,460)

无论是否有视网膜,设备都会根据需要进行转换。

Frame rects are as such:

CGRectMake(CGFloat x, CGFloat y, CGFloat width, CGFloat height)

the screen width is 320px wide by 480px tall. the status bar is 20px. thus the rect you would want is:

CGRectMake(0,0,320,460)

regardless of retina or not, the device will convert up as needed.

琴流音 2024-10-25 02:19:54

坐标以点为单位,而不是像素。无论屏幕分辨率如何,坐标系都是 320 X 480。

Coordinates are in points, not pixels. The coordinate system is 320 X 480, regardless of the resolution of the screen.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文