【发布时间】:2011-06-15 10:36:56
【问题描述】:
在 iphone 应用程序中有什么方法可以调整 UITextview 中的行之间的行距。
提前致谢。
【问题讨论】:
标签: iphone xcode uitextview
在 iphone 应用程序中有什么方法可以调整 UITextview 中的行之间的行距。
提前致谢。
【问题讨论】:
标签: iphone xcode uitextview
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.lineHeightMultiple = 50.0f;
paragraphStyle.maximumLineHeight = 50.0f;
paragraphStyle.minimumLineHeight = 50.0f;
NSString *string = @"if you want reduce or increase space between lines in uitextview ,you can do this with this,but donot set font on this paragraph , set this on uitextveiw.";
NSDictionary *ats = @{
NSParagraphStyleAttributeName : paragraphStyle,
};
[textview setFont:[uifont fontwithname:@"Arial" size:20.0f]];
textview.attributedText = [[NSAttributedString alloc] initWithString:string attributes:ats];
【讨论】:
这对我来说非常适合:
#define MAX_HEIGHT 2000
CGSize size = [text sizeWithFont:[UIFont systemFontOfSize:14]
constrainedToSize:CGSizeMake(100, MAX_HEIGHT)
lineBreakMode:UILineBreakModeWordWrap];
[textview setFont:[UIFont systemFontOfSize:14]];
[textview setFrame:CGRectMake(45, 6, 100, size.height + 10)];
textview.text = text;
【讨论】: