Chiara
Chiara

Reputation: 19

How to use size classes in xcode6

Please, is there someone who can help me to understand ho to use Size Classes in Xcode6? I'm designing for the first time a dialer. I set up different constraints, and I have no error message, and in all screens (Iphone3-4-6-6+) I have good aligned keys, but I see keys in the same size in all screen (that's not good for me, because I need they are bigger in Iphone6 and 6+). How can I do to see the right size and the right position of an object, like the key, in this case? I checked the boxes in the right panel "Use size classes" and "use autolayout", and I understood that I have to work in different optional screens that I can select in the bottom of the work area (any-any, compact-any, etc..) but I didn't understand what to do after choising a screen (example compact-any).

Upvotes: 1

Views: 168

Answers (1)

Dhaivat Vyas
Dhaivat Vyas

Reputation: 2928

Hi as per your question what you need to do when you have Any-Any size class give the constraints which you need to be common for all the views(in your case keys).

e.g. : If you want your view to remain so same height and width you need to set those constraints in Any-Any and in when you change to Custom-Any size class you just need to give constraints related to leading and trailing.

In Any-Any you just need to give widths Equally,aspect ratio and horizontal and vertical spacing between views.

The constraints highlighted in the below image are set in Any-Any Size class.

This constraints are only applied all iphones and iPad in both portrait and landscape mode.

enter image description here


In Compact-Any you just need to set leading,trailing,top and bottom spacing to views from superview or layout margin.

The constraints selected in the below image are set in Custom-Any Size class.

This constraints are only applied to all iphones in portrait and landscape mode and are not applied to iPad.

enter image description here


Result

enter image description here

Here i've not applied bottom constraints to views. but you can set if you have more controls.

Please refer the answer i've given for multiple controls with auto layout using size class.

https://stackoverflow.com/a/27471120/4101371

You can refer below links it has good explanation on auto layout using size class.

http://mathewsanders.com/designing-adaptive-layouts-for-iphone-6-plus/

http://mobileoop.com/how-to-use-auto-layout-in-xcode-6-for-ios-7-and-8-development

Hope it will be helpful in solving your issue.

Upvotes: 1

Related Questions