简体   繁体   中英

Xcode 8 Vary Traits with autolayout issue

Ok I've finally taken the plunge into autolayout using Xcode 8.

I might conceptually have the wrong idea. However I have a view in IB which has 2 labels a button and an imageview dead center in the view with dimensions 300 x 300 for 6plus and 6 devices.

在此输入图像描述

What I want to do is vary the imageview size for iPhone 5 (SE) so I click Vary for Traits and select height and width then change the values to 150 x 150 click done and the all looks good looking at iphone 5 (SE).

在此输入图像描述

在此输入图像描述

Now flicking back to 6plus and 6 its also resized to 150 x 150 but I want the image size to remain as 300 x 300. Again I may have the wrong idea completely.

I thought the whole point in this is that its varying the size dependant on what is selected ie varied.

Vary for traits or size class is not used to change autolayout for different devices, rather it is used to change layouts for Regular and Compact size of (width or height or both) .Too many devices come under regular width like ipad pro iphone 7 plus, etc. same iphone se and iphone6 in portrait mode has same width thats is Compact . So when you change for one it changes for both. When you choose vary for traits and select width+height checkbox it shows some devices in blue box it means all those will be effected.

Better do it programmatically, check device type and set size according to it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM