Sdautolayout: One line of code to fix the automatic layout! Supports cell and TableView highly adaptable, label and ScrollView content Adaptive, dedicated to making the most easy to use AutoLayout library.
"Sdautolayout Video tutorial: http://www.letv.com/ptv/vplay/24038772.html"
☆ added: Cell Height adaptive + Label Text Adaptive ☆
>>>>> tableview cell Auto height setting requires only 3 steps
1. >> Set Cell height adaptive:
// When the cell layout is set, this method can be used to achieve a high degree of self-adaptation (note: Do not use the bottom of the cell as a reference to layout its sub-view if you are highly adaptive) [Cell setupautoheightwithbottomview:_view4 bottommargin:ten];
2. >> set up TableView data sources and proxies
-(Nsinteger) TableView: (UITableView *) TableView Numberofrowsinsection: ( Nsinteger) section{ 2.1 Register model cell [self.tableview startautocellheightwithcellclass: "Cell class name" Contentviewwidth: "Contentview width"]; return _rowcount;} -(CGFloat) TableView: (UITableView *) TableView Heightforrowatindexpath: (Nsindexpath * ) indexpath{ // 2.2 get cell height based on model Span style= "color: #0000ff;" >return [Self.tableview cellheightforindexpath:indexpath Model: ' Model ' KeyPath: @ " model Property name "
Automatic layout of normal view ***********
Discard complex constraints and use runtime runtime to layout views at the right time.
0. Usage examples
/*Usage One*/_view.sd_layout.leftspacetoview (Self.view,Ten). Topspacetoview (Self.view, the). Heightis ( the). Widthratiotoview (Self.view,0.4);/*use two (one line of code, in fact, the use of a line of code)*/_view.sd_layout.leftspacetoview (Self.view,Ten). Topspacetoview (Self.view, the). Heightis ( the). Widthratiotoview (Self.view,0.4);>>Uilabel Text Adaptive://Autoheightratio () 0 automatically calculates the height according to the text (a value greater than 0 sets the ratio of height to width based on this value)_label.sd_layout.autoheightratio (0);
*******************************************************************************
Note: The view that requires automatic layout is added to the parent view and then automatically laid out, for example:
UIView *view0 = [UIViewNew]; UIView*view1 = [UIViewNew]; [Self.view addsubview:view0]; [Self.view Addsubview:view1];view0.sd_layout.leftspacetoview (Self.view,Ten). Topspacetoview (Self.view, the). Heightis ( -). Widthratiotoview (Self.view,0.4); View1.sd_layout.leftSpaceToView (View0,Ten). Topequaltoview (view0). Heightratiotoview (View0,1). Rightspacetoview (Self.view,Ten);
1. A brief analysis of usage
1.1 > Leftspacetoview (Self.view, 10)
A method with "Spacetoview" in the method name represents the spacing of a reference view, which requires passing 2 parameters: (UIView) referring to the View and (cgfloat) spacing values
1.2 > Widthratiotoview (self.view, 1)
Methods with "Ratiotoview" in the method name indicate that the width or height of the view is proportional to the corresponding property value of the reference view, and 2 parameters are passed: (UIView) refer to view and (cgfloat) multiples
1.3 > Topequaltoview (view)
A method with "Equaltoview" in the method name means that a property of view is equal to the corresponding property value of the reference view, and 1 parameters need to be passed: (UIView) Reference view
1.4 > Widthis (100)
A method with "is" in the method name means that a property value of view is equal to the parameter value, and 1 parameters need to be passed: (cgfloat) value A
Sdautolayout: An automated layout library that is easier to use than masonry