开发者

how to make content of NSString goes to next line based on \n on iphone

i have a NSString s=@"hi\nhello\n\nwelcome to this world\ni m jhon"

now how to display this content in UIlabel so that \n allow 1 line gap and \n\n allows 2 line gap

still i am getting same value

NSString *s=aDl.content;// aDl.content=hi\nhello\n\nwelcome to this world\ni m jhon





            labelb.text=s;// its same without line break  :(

kindly help me 开发者_如何学编程

Thanks


Set label's height big enough to accommodate all lines in your string. Then set label's numberOfLines property to 0 - so label will draw its text in as much lines as required. New lines symbols (\n) will be handled by label automatically:

NSString *s=@"hi\nhello\n\nwelcome to this world\ni m jhon"
label.frame = ...//big enough height
label.numberOfLines = 0;
label.text = s;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜