iPhone 设计 - 管理多个版本
我注意到 iPhone 3+ 的屏幕分辨率是 240x480,而 iPhone 4 的屏幕分辨率是 640x960 ...
这是否意味着您想要 2 组使用额外分辨率的图形?我的第一个想法是分辨率越高,图形显示的越小。
I notice that the screen resolution for the iPhone 3+ is 240x480 and the iPhone 4 is 640x960 ...
Does this mean that you'd want to have 2 sets of graphics that utilize the extra resolution? My first thought on that would be that the higher the resolution, the smaller the graphics would appear.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您确实需要两组图形。较旧的 iPhone 实际上是 320x480。一般来说,如果您愿意,您可以仅提供低分辨率图形,并且它会自动放大,但仅提供高分辨率图形不会自动工作。第二个图形的处理是根据文件名自动完成的,因此您将拥有一个名为 mygraphic.png 的文件和一个名为 [电子邮件受保护]。由于新屏幕的分辨率是旧屏幕的两倍,因此除了放置第二个文件之外,您无需执行任何特殊操作即可使其正常工作。
You do need two sets of graphics. The older iPhones are actually 320x480. In general you can provide only a low resolution graphic if you'd like, and it will be automatically upscaled, but going only one high resolution graphic doesn't work automatically. The handling of the second graphic is done automatically, based on filename, so you would have one file named mygraphic.png, and a second named [email protected]. Since the new screen is exactly double the resolution of the old screen, you don't need to do anything special to get it working beyond having the second file in place.
正如 Sam 所概述的,
UIImage
将根据文件名中是否存在@2x
自动加载适当缩放的文件。但是,您也可以通过调用[[UIScreen mainScreen] scale]
直接访问屏幕比例 - 这将在视网膜设备上返回2
和1
> 在较旧的 320x480 设备上。当使用 Core Graphics 绘制或修改图像等时,您可以使用比例值从网络上获取更高分辨率的图像。As Sam outlined,
UIImage
will automatically load the appropriately scaled file based on presence of@2x
in the filename. However, you can also access the screen scale directly by calling[[UIScreen mainScreen] scale]
-- this will return2
on retina devices and1
on older 320x480 devices. You can use the scale value to pull down higher resolution images from the web, when drawing or modifying images with Core Graphics, etc.