About adjusting Uilabel or uitextview line spacing

Source: Internet
Author: User

#define LINENUM 20//Line width

#define Lineheight 20//Row height





int begin=0;

NSString *partialstring;

nsstring* str=@ "Southeast shape wins, three Wu Metropolis, Qian Tong has been prosperous since ancient times." The Smoke Willow Painting Bridge, the wind curtain cui curtain, staggered 100,000 others. Cloud tree around the sand, roughs roll frost Snow, natural moat Infinite. The city row Zhu Ji Nanxiong, the household surplus sophistication, competes lucullan. The heavy Lake fold Qing Jia, have ploughing gui son, ten Li Lotus. Qiang tube to clear, Ling song Pan night, hippie fishing old Lotus Doll. Thousand riding high nga, drunk listen to Xiao Drum, yin appreciation haze. Alrelistingy map will be well, return to Phoenix Pond boast. Cloud tree around the sand, roughs roll frost Snow, natural moat Infinite. The city row Zhu Ji Nanxiong, the household surplus sophistication, competes lucullan. The heavy Lake fold Qing Jia, have ploughing gui son, ten Li Lotus. Qiang tube to clear, Ling song Pan night, hippie fishing old Lotus Doll. Thousand riding high nga, drunk listen to Xiao Drum, yin appreciation haze. Alrelistingy map will be well, return to Phoenix Pond boast. ";

int num = Str.length/linenum;

NSLog (@ "%d", str.length);

NSLog (@ "%d", num);

for (int i=0; i<=num; i++) {

uitextview* Textview=[[uitextview Alloc]init];

NSLog (@ "%d-----", begin);

if (i==num)

Partialstring=[str Substringwithrange:nsmakerange (Begin,str.length%linenum)];

Else

Partialstring=[str Substringwithrange:nsmakerange (Begin,linenum)];

Textview.backgroundcolor=[uicolor Clearcolor];

textview.text=partialstring;

Textview.frame=cgrectmake (0, 30+i*lineheight, 200, 30);

[Self.view Addsubview:textview];


Begin+=linenum;

NSLog (@ "%@", partialstring);

}

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.