Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AutoLayout Modify constraints

Tags:

ios

autolayout

I have a problem where I want to modify NSLayoutconstraints on a UIView but it appears a lot of the properties are readonly. I initially have four UIViews as squares in a sort of quad view and they are all tied to each other with a gap of about 20 pixels.

I have a button that increases the frame of one of those squares into full screen encompassing all others. It is at this point I would like to change the constraints of that UIView to attach it to the superviews borders at 20 pixels, that way when I rotate it it doesn't go back to the quad view but maintains full screen. It looks like the property I would want to change is 'seconditem' but this won't work. Am I approaching this problem in the wrong way? I find Autolayout a bit difficult so any help would be much appreciated

like image 955
Md1079 Avatar asked Jan 21 '15 12:01

Md1079


1 Answers

Hi you can do 2 sets of constraints :

  • 1 to manage your quad view with priority High
  • 1 to manage your fullscreen with priority Low

In the method called when you tap your button, set priority high to your fullscreen constraints and priority low to your quad view constraints.

like image 153
Vincent Avatar answered Sep 19 '22 09:09

Vincent