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