iOS adapts to text and then builds a similar effect as follows

Source: Internet
Author: User

UIView * Headview = [[UIView alloc]initwithframe:cgrectmake (0, 0, self.tbSecond.size.width, 0)];

Headview.backgroundcolor = [Uicolor Whitecolor];

UIView * view = [[UIView alloc]initwithframe:cgrectmake (Max, self.tbsecond.bounds.size.width-90, 0)];

View.layer.borderWidth = 1;

View.layer.borderColor = [Uicolor Orangecolor]. Cgcolor;

View.backgroundcolor = [Uicolor Whitecolor];

UILabel * Contentlabel = [[UILabel alloc]initwithframe:cgrectmake (self.tbsecond.bounds.size.width-120, 0)];

Contentlabel.numberoflines = 0;

Contentlabel.linebreakmode = nslinebreakbycharwrapping;

Contentlabel.font = [Uifont systemfontofsize:12];

Contentlabel.textcolor = [Uicolor Redcolor];

Contentlabel.text = visitmodel.record?visitmodel.record:@ "";

Cgsize textSize1 = [Visitmodel.record boundingRectWithSize:view.bounds.size options: Nsstringdrawinguseslinefragmentorigin | Nsstringdrawingtruncateslastvisibleline Attributes:nil context:nil].size;

NSLog (@ "%f", textsize1.height);

CGRect rect = contentlabel.frame;

Rect.size.height = textsize1.height+30;

Contentlabel.frame = rect;

[View Addsubview:contentlabel];

View.height = Rect.size.height + 45;

[Headview Addsubview:view];

Headview.height = Rect.size.height + 105;

UIView * ShowView = [[UIView alloc]initwithframe:cgrectmake (view.center.x-40, 20, 120, 40)];

Showview.backgroundcolor = [Uicolor Whitecolor];

Uiimageview * Headiv = [[Uiimageview alloc]initwithframe:cgrectmake (0, 0, 40, 40)];

Headiv.image = [UIImage imagenamed:@ "Home_circle_icon"];

[ShowView Addsubview:headiv];

Uiimageview * HEADIMV = [[Uiimageview alloc]initwithframe:cgrectmake (10, 10, 30, 30)];

HeadIMV.layer.cornerRadius = 15;

HeadIMV.layer.masksToBounds = YES;

[Headimv sd_setimagewithurl:[nsurl URLWithString:visitModel.headPicUrl] placeholderimage:[uiimage imagenamed:@ " Home_headpic "];

[ShowView ADDSUBVIEW:HEADIMV];

Uiimageview * Lianxiwo = [[Uiimageview alloc]initwithframe:cgrectmake (50, 7, 25, 25)];

Lianxiwo.image = [UIImage imagenamed:@ "Lianxiwo"];

[ShowView Addsubview:lianxiwo];

Uiimageview * Dianhua = [[Uiimageview alloc]initwithframe:cgrectmake (90, 7, 25, 25)];

Dianhua.image = [UIImage imagenamed:@ "Dianhua"];

[ShowView Addsubview:dianhua];

UIButton * lianxiwobtn = [[UIButton alloc]initwithframe:cgrectmake (45, 2, 35, 35)];

[Lianxiwobtn addtarget:self Action: @selector (Lianxiwobtnclick) forcontrolevents:uicontroleventtouchupinside];

[ShowView ADDSUBVIEW:LIANXIWOBTN];

UIButton * dianhuabtn = [[UIButton alloc]initwithframe:cgrectmake (80, 2, 35, 35)];

[Dianhuabtn addtarget:self Action: @selector (Dianhuabtnclick) forcontrolevents:uicontroleventtouchupinside];

[ShowView ADDSUBVIEW:DIANHUABTN];

[Headview Addsubview:showview];

UILabel * Companylabel = [[UILabel alloc]initwithframe:cgrectmake (view.center.x-60, headview.height-30, 120, 20)];

Companylabel.backgroundcolor = [Uicolor Whitecolor];

Companylabel.textalignment = Nstextalignmentcenter;

Companylabel.font = [Uifont systemfontofsize:14];

Companylabel.textcolor = [Uicolor Orangecolor];

Companylabel.text = visitmodel.username?visitmodel.username:@ "";

[Headview Addsubview:companylabel];

UILabel * TimeLabel = [[UILabel alloc]initwithframe:cgrectmake (self.tbsecond.bounds.size.width-60, HEADVIEW.HEIGHT-35, 60, 20)];

Timelabel.textalignment = Nstextalignmentcenter;

Timelabel.font = [Uifont systemfontofsize:12];

Timelabel.textcolor = Mrgbtocolor (0x999999);

Timelabel.text = visitmodel.time?visitmodel.time:@ "";

[Headview Addsubview:timelabel];

[Self.view Addsubview:headview];

You can also write the above-mentioned TableView Headview

Combine TableView to achieve the following effects

iOS adapts to text and then builds a similar effect as follows

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.