VFL +autolayout

Source: Internet
Author: User

One, Nslayoutconstraint API

1,constraintswithvisualformat:

+ (Nsarray *) Constraintswithvisualformat: (NSString *) format options: (nslayoutformatoptions) OPTs metrics: ( Nsdictionary *) Metrics Views: (Nsdictionary *) views;

Parameter description:

Format: This parameter is your VFL statement, for example: @ "h:|-[button]-|"

Horizontal direction H: Vertical Direction V:

views [view] superview |

Relationship >=,==,<=

Space, Gap-

Priority @value

OPTs: Enumeration parameters, default write 0, specific to your implementation of the requirements to choose the enumeration you want

Metrics: Here is a dictionary, when using dynamic Data in format such as the above sentence: @ "H:|-[button (==width)]-|", indicating that the width of the button is wide, then where to find this parameter? is to find the value of key pair in this dictionary, if you do not find this value, the app will be crash.

Views: As the name implies, this is all you use in the VFL view, that in the above example should be how to preach it? The result is this: nsdictionaryofvariablebindings (button). If you use multiple view, you can nsdictionaryofvariablebindings (button,button1 , Button3 ...), this name also corresponds to one by one of the parameter format, which is indispensable.

2, AddConstraint:

-(void) AddConstraint: (Nslayoutconstraint *) constraint Ns_available_ios (6_0);  This method is deprecated in a future release and should is avoided. Instead, set Nslayoutconstraint ' s active property to yes.-(void) addconstraints: (Nsarray *) Constraints Ns_available_ios (6_0);  This method is deprecated in a future release and should is avoided. Instead use +[nslayoutconstraint activateconstraints:].-(void) Removeconstraint: (Nslayoutconstraint *) constraint NS_ Available_ios (6_0);  This method is deprecated in a future release and should is avoided. Instead set Nslayoutconstraint ' s active property to no.-(void) removeconstraints: (Nsarray *) Constraints Ns_available_ IOS (6_0);  This method is deprecated in a future release and should is avoided. Instead use +[nslayoutconstraint deactivateconstraints:].

eg

Second, in the coding mode, 1.addConstraint (s) before the view should go to the ministry was addsubview up. 2. Do not write frame3 to views. Turn off Autoresizeingmask for the necessary view. [_aview Settranslatesautoresizingmaskintoconstraints:no];4.uilabel to write Linebreakmode, to write NumberOfLines ( iOS7.0 default seems to be 1, Pit Daddy) 5.UILabel to change the line, be sure to add preferredmaxlayoutwidth. Otherwise, the width cannot be initialized.

 

VFL +autolayout

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.