Search code examples
objective-cautolayout

Adjusting subviews to keep their size using auto layout


I have a UIView that contains subviews that looks like this:

enter image description here

This view was originally designed with 320 width in mind. iPhone 5s and lower. However I am now adapting it to work with iPhone 6+

The issue I am facing is getting the subviews width to grow to accommodate the extra space on the left and right of their super view. I can only seem to get the centre views width to grow, however not the out views. What constraints would I need to apply or change in order to get all views to grow a little to accommodate the extra space on the sides?


Solution

  • ScreenShot of views

    Hi!

    If you design your view in interface builder, you may try this:

    1- set all views to specific width and height 2- the view at the corner add pin to the edge with static value. 3- the view in the middle add pin to top or bottom, and add align constraint to horizontal centre of superview

    Not sure if this help, Just try to answer!