iOS10 之 Vary for Traits

官方文档:

Create user interface variations for different device configurations

不同的设备创建不同的用户界面

In Interface Builder, you can add, remove, and editvariations of the user interfacefor different device configurations using thedevice configuration pane. Before you create a variation,choose a device configurationthat you want to vary.

在IB下,你可以使用设备配置面板为不同配置的设备添加,移除,和编辑不同的用户界面。在你创建一个变化之前,需要选择你想要去变动的设备配置。

1、

In the devices configuration pane, click the “Vary for” button.

The device configuration pane shows all of the affected devices for this configuration.

点击vary for按钮,设备配置面板展示了所有受这个配置影响的设备

2、For iOS apps, in the popover(浮出层) that appears, select thesize class(width, height, or both).

The size classtraitsdefine an abstract or real screen size on an iOS device. After selecting traits, dismiss the popover by clicking anywhere in Interface Builder.

对于iOS app,在显示的悬浮窗上,选择size class,定义了iOS设备抽象或真实的屏幕尺寸,点击IB任意处让悬浮窗消失。


The device configurations pane shows the affected devices.


3、

Make the changes for this device configuration in Interface Builder.

While in the variation mode, any changes to the canvas, create a variation for the current device configuration or update an existing variation.

设置变化之处,在变化模式中,对全局的任何更改,都是为当前配置的设备创建的变化或更新现有的变化。

4、

Click the “Done Varying” button.

Interface Builder stops adding variations to view attributes and constraints on the canvas.

点击Done Varying,完成当前配置变化的添加,展示全局的属性和约束。


Size Class

Regular 标准,表示长。

Compact 紧凑,表示短。

相同尺寸的设备的size class是一致的。

1、ipad  横屏竖屏都是(R ,R),9.7寸与12.9寸的情况一样。



2、ipad 下对应splitView的情况,只有显示区域超过为2/3的界面才是(R,R),其余的都是(C,R)

其他尺寸的不同情况都是相通的,由显示区域的大小来决定。





3、iPhone 竖屏都是(C,R),其他机型也都是一样的。



4、iPhone 7 plus (5.5寸)横屏 是 (R,C)


5、iPhone 7(4.4寸)/SE(4寸)/4S(3.5寸) 横屏都是 (C,C)


Vary  for  Traits

1、什么都不选的时候,默认为(*,*),即通用界面,所有尺寸设备通用。我们通过Device和Orientation可以组合出所有尺寸设备的横竖屏情况。


2、在view as上显示wC的时候,选择Width,表示锁定当前Width的模式,即表示(C,*),即(C,C)和(C,R)通过前面的Size Class可以得到差不多是14种:

1) iPhone竖屏  (C,R)4种

2) iPhone横屏,除了plus(5.5寸) (C,C)3种

3) iPad splitView下,显示区域小于2/3的,(C,R)7种


3、在view as上显示hC的时候,选择Height,表示锁定当前Height的模式,表示(*,C),即(C,C)和(R,C)跟第2种情况是有交集(C,C),有4种:

1)iPhone横屏,plus(5.5寸) (R,C)1种

2)iPhone横屏,除了plus(5.5寸) (C,C)3种

其实就是iPhone的横屏模式。


4、在view as上显示wR的时候,选择Width,表示锁定当前Width的模式,表示(R,*),即(R,C)和(R,R)

5、在view as上显示hR的时候,选择Height,表示锁定当前Height的模式,表示(*,R),即(R,R)和(C,R)

6、在view as上显示wC hC的时候,选择Height和Width,即表示(C,C)

7、在view as上显示wC hR的时候,选择Height和Width,即表示(C,R)

8、在view as上显示wR hC的时候,选择Height和Width,即表示(R,C)

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 开发移动网页时,你一定会遇到下面这段代码: 在网页的 中增加以上这句话,可以让网页的宽度自动适应手机屏幕的宽度。其...
    gzgogo阅读 2,290评论 4 16
  • 转自:http://blog.csdn.net/highning0007/article/details/3799...
    某人在阅读 1,748评论 0 0
  • 本篇文章是基于谷歌有关Graphic的一篇概览文章的翻译:http://source.android.com/de...
    lee_3do阅读 7,209评论 2 21
  • 一、集中式工作流 有两个开发者小明和小红,看他们是如何开发自己的功能并用git工作流来协作的 有人先初始化好中央仓...
    木木的mt阅读 603评论 0 0
  • 今有某人姓叶,人称叶子。 年少时一度爱看异能人士的传说,并偶尔喜欢幻想下自己也拥有某种超能力,那样等心情好时,就可...
    某花草阅读 306评论 8 1