Customize the frame settings for each space in the cell QQ as an example

Source: Internet
Author: User

-(void) Setmessage: (Gylmessagemodel*) Message

{

_message = message;

// width of the screen

cgfloat screenwidth = [uiscreen mainscreen]. Bounds. Size. width;

// Clearance

cgfloat padding = ten;

// Time

cgfloat TimeX = 0;

cgfloat timey = 0;

cgfloat Timew = screenwidth;

cgfloat Timeh = ;

_timef = cgrectmake(TimeX, Timey, Timew, Timeh);

//2. Avatar

cgfloat iconh = ;

cgfloat iconw = ;

cgfloat icony = cgrectgetmaxy(_timef) + padding;

cgfloat IconX = 0;

if (gylmessagemodeltypeme = = _message. type ) {// sent by oneself

//x = screen width - gap - avatar width

IconX = screenwidth-padding-iconw;

}Else IconX = padding;

_iconf = cgrectmake(IconX, Icony, Iconw, Iconh);

//3. Body

nsdictionary * dict = @{nsfontattributename :gyltextfont} ;

    cgsize  maxsize = CGSizeMake ( Span style= "Color:rgb (39,42,216)" >200 ,  maxfloat );

     cgsize  textsize = [ _message text   boundingrectwithsize:maxSize  options: Nsstringdrawinguseslinefragmentorigin   attributes:d ict  context : nil size

cgfloat textw = textSize. width;

cgfloat texth = textSize. height;

cgfloat texty = icony;

cgfloat textx = 0;

     if   ( gylmessagemodeltypeme ==  _message type // self-made

//x = avatar x- Gap - width of text

TEXTX = ICONX-PADDING-TEXTW;

}Else

{

maximum x+ clearance of// avatar

TEXTX = cgrectgetmidx(_iconf) + padding;

}

_TEXTF = cgrectmake(TEXTX, texty, TEXTW, texth);

//4. Row Height

cgfloat maxicony = cgrectgetmaxy(_iconf);

cgfloat maxtexty = cgrectgetmaxy(_textf);

//_cellheight = (Maxicony > maxtexty?) (Maxicony + padding): (maxicony + padding));

_cellheight = MAX(maxicony, maxtexty) + padding;

}


Customize the frame settings for each space in the cell QQ as an example

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.