NSUser
NSUser

Reputation: 1233

stuck in concept of auto layout in Xcode 6.4

I just started to learn auto layout.

I have switched off the Use Size Classes.

I make there UILabels which is shown in the image and their constraints also. I want to look similar in 4s,5s,6 and 6Plus.

But it is working fine on 4s and 5s but distorts in 6 and 6Plus.

Why this is happening and how can I resolve this.

My StoryBoard with constraints:

enter image description here

Output iN 5s enter image description here

Output IN 6 and 6Plus

enter image description here enter image description here

Upvotes: 0

Views: 37

Answers (2)

user5426320
user5426320

Reputation:

Assuming that the way labels are placed in 5s is what you are really looking for, place the constraints as follows :

  1. Pin width of all labels equally.
  2. Pin Height of all labels
  3. Pin vertical position of all labels from top margin equally.
  4. Now, as for the problem, add the constraints as follows for horizontal placement of labels : [leading margin--0--label1--40--label2--<=20--label3--Trailing margin]

Adding the horizontal constraints should work for all sizes.

Upvotes: 2

Nitzan R
Nitzan R

Reputation: 78

This happens because none of your constraints is hooked to the leading/trailing layout guide. What you'll want to do is to attach labels 1 & 3 to the "sides" of the view, and then attaching label 2's constraints accordingly. (I would recommend adding a center horizontally constraint, but it can be achieved by different ways).

Upvotes: 0

Related Questions