Code Control AutoLayout

Source: Internet
Author: User

-(void) setupview{//code way to implement automatic layout VFL//create a tableview;UITableView *tableview =[[UITableView alloc] init]; //Tableview.backgroundcolor = [Uicolor redcolor];TableView.Delegate=Self ;#warningThe code implements the automatic layout, to set the following property to Notableview.translatesautoresizingmaskintoconstraints=NO;    [Self.view Addsubview:tableview]; Self.tableview=TableView; //Create an input box viewWcinputview *inputview =[Wcinputview Inputview]; Inputview.translatesautoresizingmaskintoconstraints=NO;        [Self.view Addsubview:inputview]; //Automatic Layout//horizontal-oriented constraintsNsdictionary *views = @{@"TableView": TableView,@"Inputview": Inputview}; //1.tabview Horizontal direction constraintsNsarray *tabviewhconstraints = [Nslayoutconstraint constraintswithvisualformat:@"h:|-0-[tableview]-0-|"Options0Metrics:nil Views:views];        [Self.view addconstraints:tabviewhconstraints]; //2.inputView Horizontal direction constraintsNsarray *inputviewhconstraints = [Nslayoutconstraint constraintswithvisualformat:@"h:|-0-[inputview]-0-|"Options0Metrics:nil Views:views];            [Self.view addconstraints:inputviewhconstraints]; //the vertical direction of the constraintNsarray *vcontraints = [Nslayoutconstraint constraintswithvisualformat:@"V:|-64-[tableview]-0-[inputview (]-0-|)"Options0Metrics:nil Views:views];    [Self.view addconstraints:vcontraints]; Self.inputviewconstraint=[Vcontraints Lastobject]; NSLog (@"%@", vcontraints);}

Code Control 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.