Previously wrote a masonry to achieve automatic layout of the essay, today bored to find another automatic layout of the third-party framework keep layout, the use of feeling more simple than masonry, compared to easy to understand?
Attached Source Address: https://github.com/iMartinKiss/KeepLayout
A description of some properties:
Relationships between attributes and precedence:
For more information, please refer to the website description.
Enclose the code for the simple automatic layout as well:
1- (void) Viewdidload {2 [Super Viewdidload];3 //additional setup after loading the view, typically from a nib.4 5 [self setupfourviews];6 7 }8- (void) Setupfourviews {9 TenUIView *redview =[[UIView alloc] init]; One ARedview.backgroundcolor =[Uicolor Redcolor]; - [Self.view Addsubview:redview]; - the -UIView *blueview =[[UIView alloc] init]; -Blueview.backgroundcolor =[Uicolor Bluecolor]; - [Self.view Addsubview:blueview]; + -UIView *greenview =[[UIView alloc] init]; + AGreenview.backgroundcolor =[Uicolor Greencolor]; at [Self.view Addsubview:greenview]; - - -UIView *purpleview =[[UIView alloc] init]; -Purpleview.backgroundcolor =[Uicolor Purplecolor]; - [Self.view Addsubview:purpleview]; in - [self Testwithredview:redview blueview:blueview]; to + [self Testwithgreenview:greenview purpleview:purpleview]; - the } *- (void) Testwithgreenview: (UIView *) Greenview Purpleview: (UIView *) Purpleview { $ Panax NotoginsengGreenView.keepBottomInset.equal = -;//the bottom spacing from the parent view is -GreenView.keepLeftInset.equal = -;//left spacing from parent view is theGreenview.keeprightoffsetto (purpleview). Equal = -;//the right distance from the Blueview is +GreenView.keepHeight.equal = -;//height is AGreenview.keepwidthto (purpleview). Equal =1;//width and Blueview equal the +Purpleview.keepbottomalignto (greenview). Equal =1;//align with the bottom of the Redview -PurpleView.keepRightInset.equal = -;//the right distance from the parent view is $Purpleview.keepheightto (greenview). Equal =2;//twice times the height of the redview. $ } - -- (void) Testwithredview: (UIView *) redview Blueview: (UIView *) Blueview { the -RedView.keepTopInset.equal = -;//the top distance from the parent view isWuyiRedView.keepRightInset.equal = -;//the right distance from the parent view is theRedView.keepLeftInset.equal = -;//left spacing from parent view is -RedView.keepHeight.equal = -; Wu -BlueView.keepLeftInset.equal = -;//left spacing from parent view is AboutBlueView.keepRightInset.equal = -;//the right distance from the parent view is $Blueview.keeptopoffsetto (redview). Equal = -;//the top distance from the Redview is -Blueview.keepheightto (redview). Equal =1;//the height and redview are equal -}
Simple automatic layout with third-party framework Keep layout