不同分辨率下页面的控件大小调整(待完善)

来源:互联网 发布:idm mac破解版 编辑:程序博客网 时间:2024/06/11 03:51

Retina: 960×640的分辨率压缩到一个3.5英寸的显示屏内。

ios4/ios4s 2010/2011

Screen Res 960×640

Screen Size (inches) 3.5


ios5 2012

Screen Res 1136×640

Screen Size (inches) 4

像素定义:像素是指基本原色素及其灰度的基本编码。

分辨率(resolution)就是屏幕图像的精密度,是指显示器所能显示的像素的多少。由于屏幕上的点、线和面都是由像素组成的,显示器可显示的像素越多,画面就越精细,同样的屏幕区域内能显示的信息也越多,所以分辨率是个非常重要的性能指标之一。可以把整个图像想象成是一个大型的棋盘,而分辨率的表示方式就是所有经线和纬线交叉点的数目。

为了方便开发人员开发,iOS 中统一使用点(Point)对界面元素的大小进行描述。(pts)
所以对于不同分辨率下的界面编写,只需把屏幕大小都当成 320 x 480点 进行开发即可,点跟像素的换算关系如下:
普屏 1点 = 1像素 
Retina屏 1点 = 2像素 

直接通过 [[UIScreen mainScreen] bounds] 即可获取到当前屏幕的基础分辨率,所以不用 hard code。

而元素的位置相对当前屏幕设定

http://www.zhihu.com/question/20583941

个人设置:
Button  40×80

TextField  40×100

Label  40×80

控件尺寸

http://dangpu.sinaapp.com/?p=59

Points VS. Pixels

    The iPhone 4 introduced a high resolution display with twice the pixels of previous iPhones. However you don't have to modify your code to support high-res displays; the coordinate system goes by points rather than pixels, and the dimensions in points of the screen and all UI elements remain the same.

    iOS 4 supports high resolution displays (like the iPhone 4 display) via the scale property on UIScreen, UIView, UIImage, and CALayer classes. If the object is displaying high-res content, its scale property is set to 2.0. Otherwise it defaults to 1.0.
    All you need to do to support high-res displays is to provide @2x versions of the images in your project. See the checklist for updating to iOS4 or Apple documentation for Supporting High Resolution Screens for more info.

Iphone4 的显示是以前iphone两倍像素的分辨率。但是你不用修改你的代码来支持更高的显示效果;因为系统的协调模块描述显示使用点(point)而不是像素,而屏幕和所有UI控件上点的量度是保持不变的。

不是专业翻译,省略以下...


原创粉丝点击