I have a UIImageView
embedded in a UIView
. My entire app uses AutoLayout
, but I want to remove constraints
for the UIImageView
. Xcode
will not allow me to delete the constraints
, is there a way to disable them for a specific object, set them to zero, something?
To remove a single constraint just select it and hit delete. To remove constraints for a single view you select the view and hit the triangle button in the bottom right hand corner... And hit "Clear Constraints" under the "Selected Views" part.
Just select the view you want to remove a constraint from and open the size inspector. You should see a list of all the constraints. Select the one you want to delete, and press the delete key.
Auto Layout defines margins for each view. These margins describe the preferred spacing between the edge of the view and its subviews. You can access the view's margins using either the layoutMargins or layoutMarginsGuide property. The layoutMargins property lets you get and set the margins as a UIEdgeInsets structure.
I agree Xcode auto-layout is horrible to use if you want something particular...
What I use to remove constraints programatically:
[detailsPhotoView removeConstraints:detailsPhotoView.constraints];
In XCode 5 there is an option while editing constraints 'Remove at build time'. If this is enabled the constraint will automatically be removed during run-time. The option is there to keep Interface Builder happy if you don't want particular constraints.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With