Haider
Haider

Reputation: 4961

iOS Autolayout to set width and height according to screen size

What constraints I should add to set width and height proportional to the Superview (in my case its the UIViewController's view) in iOS Autolayout, with Autoresizing we can do like the pic shown below.

enter image description here

Upvotes: 3

Views: 2456

Answers (1)

Thanveer Ahammed
Thanveer Ahammed

Reputation: 148

if a uiview in a uiviewcontroller.

  1. you must add centre horizontally and vertically in container constraint for that uiview.

  2. you need to add equal height and equal width constraint for that uiview with your super view.

  3. select both equal height constraint and equal width constraint and add multiplier to that constraint as your needs.

Upvotes: 4

Related Questions