Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

enter image description here

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).

enter image description here

enter image description here

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 i.e. varied.

like image 858
Alex McPherson Avatar asked Nov 02 '16 15:11

Alex McPherson


1 Answers

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.

like image 110
papaCook Avatar answered Oct 31 '22 23:10

papaCook