我创建了一个普通的UILabel,并希望能够为UILabel中的文本添加行间距.
虽然我这样做会影响adjustsFontSizetoFitWidth,它不再适合UILabel.
我用过的一些代码:
var userQuestionsAnswer = UILabel(frame: CGRectMake(0,20,20)) userQuestionsAnswer.font = UIFont(name: Font.GothamBlack,size: 15) userQuestionsAnswer.numberOfLines = 0 userQuestionsAnswer.adjustsFontSizetoFitWidth = true var style = NSMutableParagraphStyle() style.linespacing = view.frame.size.height * 0.021 style.alignment = NSTextAlignment.Center let attributes = [NSParagraphStyleAttributeName : style] var answerText = "This is the answer" self.userQuestionsAnswer.attributedText = NSAttributedString(string: answerText!,attributes:attributes)
任何人都可以告诉我为什么这是我以及如何解决它?
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。