如何在 swift 3 中制作一个 UILabel 或 UITextView 来实现这一点。
这里有标签的解决方案。
let label = UILabel()
let stringValue = "How to implement LineSpacing and Background color of text with a UILabel"
let attrString = NSMutableAttributedString(string: stringValue)
var style = NSMutableParagraphStyle()
style.lineSpacing = 24 // change line spacing between paragraph like 36 or 48
style.minimumLineHeight = 20 // change line spacing between each line like 30 or 40
attrString.addAttribute(NSParagraphStyleAttributeName, value: style, range: NSRange(location: 0, length: stringValue.characters.count))
// background color
attrString.addAttribute(NSBackgroundColorAttributeName, value: UIColor.red, range: NSRange(location: 0, length: stringValue.characters.count))
label.attributedText = attrString
关于ios - 如何使用 UILabel 或 UITextview 实现文本的 LineSpacing 和背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46541357/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |