After IOS adds AutoLayout in Xib or storyboard, modify the AutoLayout constraint in your code

Source: Internet
Author: User

If it is Viewcontrol, the AutoLayout adaptation is written in the -(void) Updateviewconstraints method to modify the constraint;

If the view is autolayout fit in -(void" in the Updateconstraints method.

You can simply drag a view constraint as a drag control into a property directly in the following method to change the

//traverse self. MyView the constraints in the control, locate the Nslayoutattributeheight control height constraint, and then modify the

-(void) updateviewconstraints

{


[Superupdateviewconstraints];

Nsarray *constrains = self . MyView. constraints;

For (nslayoutconstraint *constraint inconstrains) {

if (constraint. FirstAttribute = =nslayoutattributeheight) {

Constraint. constant = 50.0;

}

}

}


Note: Be sure to add the words "Super Updateviewconstraints" to the method. Otherwise it will be an error

After IOS adds AutoLayout in Xib or storyboard, modify the AutoLayout constraint in your code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.