我有 UITextView,我想将它的行高设置为 50.0f,所以我使用了 typingAttributes,但没有任何效果,我的代码在 ViewDidAppear 方法中是这样的
UITextView *textView = [[UITextView alloc]initWithFrame:CGRectMake(0, 0, 300, 300)];
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.minimumLineHeight = 50.0f;
paragraphStyle.lineHeightMultiple = 50.0f;
paragraphStyle.maximumLineHeight = 50.0f;
NSDictionary *textViewAttributeDic = [NSDictionary dictionaryWithObject:paragraphStyle forKey:NSParagraphStyleAttributeName];
textView.typingAttributes = textViewAttributeDic;
文本不受设置类型属性的影响,我尝试使用类型属性更改颜色和字体但没有任何效果
我已阅读所有堆栈答案和文档
我做错了什么:(
更新: 我什至尝试过
UITextView *textView = [[UITextView alloc]initWithFrame:CGRectMake(0, 0, 300, 300)];
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.minimumLineHeight = 50.0f;
paragraphStyle.lineHeightMultiple = 50.0f;
paragraphStyle.maximumLineHeight = 50.0f;
NSDictionary *textViewAttributeDic = [NSDictionary dictionaryWithObject:paragraphStyle forKey:NSParagraphStyleAttributeName];
textView.attributedText = [[NSAttributedString alloc] initWithString:@"" attributes:textViewAttributeDic];
当我尝试
textView.attributedText = [[NSAttributedString alloc] initWithString:@"blahblah" attributes:textViewAttributeDic];
它有效,但我需要没有空格或“blah”字符的空文本视图