IOS Masonry Auto Layout

Source: Internet
Author: User

Before the project with a frame layout, the project login with the VFL, and later felt with masonry, the day before the layout Tableviewcell used the next, feel good.

#import " Masonry.h " #import " MASViewAttribute.h "

Look first:

#import "ReportsCell.h"//#import "Masonry.h"#import "YZPUIFormatMacros.h"#import "Global.h"Static ConstCGFloat kiconwidth =55.0f;Static ConstCGFloat kiconheight =55.0f;@implementationReportscell- (ID) Initwithstyle: (Uitableviewcellstyle) style Reuseidentifier: (NSString *) reuseidentifier{ Self=[Super Initwithstyle:style Reuseidentifier:reuseidentifier]; if(self) {Self.backgroundcolor=[Uicolor Whitecolor]; UIView*headerview =[[UIView alloc]init]; Headerview.backgroundcolor=Yzpcolordividinglineoutdide;        [Self addsubview:headerview]; [Headerview mas_makeconstraints:^ (Masconstraintmaker *Make ) {Make.left.equalTo (@0); Make.top.equalTo (@0);            Make.width.equalTo (@ (mainwidth));        Make.height.equalTo (@ (yzpspacehsmall));        }]; UIView*topline=[self lineview];        [Headerview Addsubview:topline]; [TopLine mas_makeconstraints:^ (Masconstraintmaker *Make )            {Make.top.equalTo (headerview.top);            Make.left.equalTo (Headerview.left);            Make.width.equalTo (Headerview.width); Make.height.equalTo (@0.5);                }]; UIView*bottomline=[self lineview];        [Headerview Addsubview:bottomline]; [Bottomline mas_makeconstraints:^ (Masconstraintmaker *Make ) {Make.top.equalTo (Headerview.bottom). With.offset (-0.5);            Make.left.equalTo (Headerview.left);            Make.width.equalTo (Headerview.width); Make.height.equalTo (@0.5);                }]; _orderidlabel=[[UILabel alloc]init]; _orderidlabel.font=Yzpfontsubhead; _orderidlabel.textcolor=Yzpcolortextsubhead;        [Self Addsubview:_orderidlabel]; [_orderidlabel mas_makeconstraints:^ (Masconstraintmaker *Make ) {Make.top.equalTo (Headerview.bottom). With.offset ( the); Make.left.equalTo (@Ten);            Make.width.equalTo (Headerview.width); Make.height.equalTo (@ -);                }]; _ordericonview=[[Uiimageview alloc]init];        [Self addsubview:_ordericonview]; [_ordericonview makeconstraints:^ (Masconstraintmaker *Make ) {Make.left.equalTo (@ the); Make.top.equalTo (_orderidlabel.bottom). With.offset ( the);            Make.width.equalTo (@ (kiconwidth));        Make.height.equalTo (@ (kiconheight));                        }]; _ordertitlelabel=[[UILabel alloc]init]; _ordertitlelabel.font=Yzpfontsubhead; _ordertitlelabel.textcolor=[uicolor colorwithred:0.141fGreen0.141fBlue0.141fAlpha1.00f]; _ordertitlelabel.numberoflines=2;        [Self Addsubview:_ordertitlelabel]; [_ordertitlelabel mas_makeconstraints:^ (Masconstraintmaker *Make ) {Make.left.equalTo (_ordericonview.right). With.offset ( the); Make.top.equalTo (_ordericonview.top). With.offset (2); Make.width.equalTo (@ (mainwidth- the)); Make.height.lessThanOrEqualTo (@ ( *));                }]; _orderspeclabel=[[UILabel alloc]init]; _orderspeclabel.font=Yzpfontexplain; _orderspeclabel.textcolor=[uicolor colorwithred:0.400fGreen0.400fBlue0.400fAlpha1.00f];        [Self Addsubview:_orderspeclabel]; [_orderspeclabel mas_makeconstraints:^ (Masconstraintmaker *Make )            {Make.left.equalTo (_ordertitlelabel.left); Make.top.equalTo (_ordertitlelabel.bottom). Offset (Ten); Make.width.equalTo (@ (mainwidth-135)); Make.height.lessThanOrEqualTo (@ ( -));                }]; _productscountlabel=[[UILabel alloc]init]; _productscountlabel.font=yzpfontcontent; _productscountlabel.textalignment=Nstextalignmentright; _productscountlabel.textcolor=[uicolor colorwithred:0.400fGreen0.400fBlue0.400fAlpha1.00f];        [Self Addsubview:_productscountlabel]; [_productscountlabel mas_makeconstraints:^ (Masconstraintmaker *Make )            {Make.top.equalTo (_ordertitlelabel.top); Make.left.equalTo (_ordertitlelabel.right). Offset (5); Make.right.equalTo (self.right). With.offset (- the);        Make.height.equalTo (_ordertitlelabel.height);                }]; UIView*centerline=[self lineview];        [Self addsubview:centerline]; [CenterLine mas_makeconstraints:^ (Masconstraintmaker *Make ) {Make.top.equalTo (_ordericonview.bottom). Offset ( the);            Make.left.equalTo (self);            Make.width.equalTo (self); Make.height.equalTo (@0.5);                }]; _usernamelabel=[[UILabel alloc]init]; _usernamelabel.font=Yzpfontexplain; _usernamelabel.textcolor=Yzpcolortextexplain;//_usernamelabel.numberoflines=2;_usernamelabel.textalignment=Nstextalignmentleft;        [Self Addsubview:_usernamelabel]; [_usernamelabel mas_makeconstraints:^ (Masconstraintmaker *Make ) {Make.left.equalTo (self.left). With.offset ( the); Make.top.equalTo (Centerline.bottom). Offset (Ten); Make.width.lessThanOrEqualTo (@ Max); Make.height.lessThanOrEqualTo (@ *);                }]; _userphonelabel=[[UILabel alloc]init]; _userphonelabel.font=Yzpfontexplain; _userphonelabel.textcolor=Yzpcolortextexplain; _userphonelabel.textalignment=Nstextalignmentright;        [Self Addsubview:_userphonelabel]; [_userphonelabel mas_makeconstraints:^ (Masconstraintmaker *Make )            {Make.top.equalTo (_usernamelabel.top); Make.right.equalTo (self.right). With.offset (- the); Make.height.lessThanOrEqualTo (@ *); Make.width.lessThanOrEqualTo (@ Max);                }]; _useraddresslabel=[[UILabel alloc]init]; _useraddresslabel.font=Yzpfontexplain; _useraddresslabel.textcolor=Yzpcolortextexplain;        [Self Addsubview:_useraddresslabel]; [_useraddresslabel mas_makeconstraints:^ (Masconstraintmaker *Make ) {Make.top.equalTo (_usernamelabel.bottom). With.offset (Ten); Make.left.equalTo (Self.left). With.offset ( the);//Make.bottom.equalTo (Self.bottom). With.offset ( -10);Make.width.equalTo (self.width); Make.height.lessThanOrEqualTo (@ *);        }]; }    returnSelf ;}-(UIView *) lineview{UIView*line=[[UIView alloc]init];//Line.backgroundcolor=[uicolor Redcolor];Line.backgroundcolor=[uicolor colorwithred:0.800fGreen0.800fBlue0.800fAlpha1.00f]; returnLine ;}- (void) awakefromnib {//Initialization Code}- (void) setselected: (BOOL) selected animated: (bool) animated {[Super setselected:selected animated:animated]; //Configure The View for the selected state}@end

IOS Masonry Auto Layout

Related Article

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.