iOS label self-applicable size

Source: Internet
Author: User

[Self.lable setnumberoflines:0];

[Email protected] "In recent years, despite the beautiful trading data, but after a year of operation, Lao Wang found that speculation is still no profit space. He finally understand that house prices have lost the rise of the soil environment, mainly inventory of large inventories, the traditional enterprise survival difficult, the desire for young people to reduce housing, asset allocation to the capital market, "speculation has arrived at the end of the" [2006 to 2011, Wenzhou City, urban housing sales average price from 8045 yuan/ Square meters rose to 34674 yuan/square meters, 5 years time has risen 3 times times or so. Lao Wang said, wenzhou price per square meter from 10,000 yuan to 20,000 yuan, spent more than a year, from 20,000 yuan to 30,000 yuan, only a year less than. ][2009, Wenzhou, per capita GDP of only 4604 U.S. dollars, in Zhejiang Province ranked third, less than half of Hangzhou, Zhejiang Province, only 71% of GDP per capita. ]";

Self.lable.backgroundcolor=[uicolor Graycolor];

Set paragraph style

Nsmutableparagraphstyle *par=[[nsmutableparagraphstyle Alloc]init];

par.lineheightmultiple=nslinebreakbycharwrapping;

Set paragraph font style

Nsdictionary *[email protected]{nsfontattributename:self.lable.font,nsparagraphstyleattributename:par.copy};

Calculates the actual size of the lable returns the area where the text is drawn

CGRect rect=[self.lable.text Boundingrectwithsize:cgsizemake (Self.view.frame.size.width, Self.view.frame.size.height) Options:nsstringdrawinguseslinefragmentorigin Attributes:dic Context:nil];

Set the distance of the label to the top of the screen

Self.lable.frame=cgrectmake (0, Rect.size.width, rect.size.height);

[Self.view addSubview:self.lable];

iOS label self-applicable size

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.