开发者

Creating paragraphs in UITextview

Is it possible to split the text into par开发者_StackOverflowagraph in a UITextView?


It's possible.

Example:

UITextView *testTextView = [[UITextView alloc] initWithFrame:frame];

[testTextView setText:@"More\nBooks"];

It's displayed like 2 strings:

More

Books

Key for answer is: \n - end of line symbols.


use NSMutableParagraphStyle in attributed string. and check other properties instead of paragraphSpacingBefore;

NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
            paragraphStyle.paragraphSpacingBefore = 33.;

_textView.attributedText = [[NSAttributedString alloc] initWithString:string attributes:@{NSParagraphStyleAttributeName: paragraphStyle}];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜