Mohamed Salad
Mohamed Salad

Reputation: 179

Constraints have me fumbling

Tried a lot of combinations with the x,y,width and height using auto layout but have had no luck. For frame of reference check out this image of iPhone 7s on storyboard

*Remember the OFF in relation to the fries in the background

iPhone 7s

Then check out this

iPhone 5

I'm very confused on what to do.

Upvotes: 0

Views: 50

Answers (1)

Ben Ong
Ben Ong

Reputation: 931

If you want a View to be in a certain portion of its superview, you can use align constraint with multiplier. First apply these constraints you your view:

enter image description here

Then modify each of the multiplier to the portion you want it to be, from the center to the edge is between value 1 to 2:

enter image description here enter image description here

Note the values I used(1.7 & 1.9) brings the center of the view to 70% and 90% point between the center and edge of the superview. Having the multiplier at 2 will guarantee half your view be outside your superview.

Reminder too that these two constraints only determines the X and Y position of your view. You will need to add more to determine its width and height which I did beforehand.

Upvotes: 3

Related Questions