IOS Label Wrap IOS6 and IOS7

Source: Internet
Author: User

IOS 6 and iOS7 are not the same, so we separate them:

IOS6:

//    calculates the actual frame size and turns the label frame to the actual size Cgsize size01 = [ssizewithfont:[uifontsystemfontofsize:15.0f]constrainedtosize:sizelinebreakmode:    Nslinebreakbywordwrapping]; [Label Setframe:cgrectmake (ten,size01.width, size01.height)];

IOS7:

UILabel *label = [[UILabel alloc] Initwithframe:cgrectmake (0,0, -, $)]; NSString*str=@"Hair Evil can not grandma ask service on the gnawing found I see can as soon as possible stability fine amount for you holiday"; Label.text=str; Uifont*font=[uifont systemfontofsize: the]; Label.font=font; //Split LineLabel.linebreakmode=nslinebreakbywordwrapping; //set Multiple lines[Label Setnumberoflines:0]; //set the width and height of the maximum sizeCgsize Size=cgsizemake ( -, +); //Get current fontNsdictionary *[email protected]{nsfontattributename: [Uifont systemfontofsize: the]}; Cgsize authsize=[str boundingrectwithsize:size options:nsstringdrawinguseslinefragmentorigin    Attributes:dict context:nil].size; Label.frame=cgrectmake ( -, -, Authsize.width, authsize.height); [Self.view Addsubview:label];

IOS Label Wrap IOS6 and IOS7

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.