我想使标签格式线成为不同大小的标签文本字的动态形状如何使用核心文本框架
请在Dynamic arrange label text上的动态形状生成上显示此类型格式Diffent font style arrange
请建议使用 coustom 库来制作此类型格式
最佳答案
我只是用 NSAttributedString 向您展示方向,您必须弄清楚其余的细节,例如正确的字体、大小、样式、行间距等。(提示:检查 NSMutableParagraphStyle)
let attr = NSMutableAttributedString(string: "")
attr.appendAttributedString(NSAttributedString(string: "The\n", attributes: [NSFontAttributeName: UIFont.boldSystemFontOfSize(60), NSForegroundColorAttributeName: UIColor.greenColor()]))
attr.appendAttributedString(NSAttributedString(string: "HAPPINESS OF\n", attributes: [NSFontAttributeName: UIFont.systemFontOfSize(45), NSForegroundColorAttributeName: UIColor.redColor()]))
attr.appendAttributedString(NSAttributedString(string: "YOUR LIFE\n", attributes: [NSFontAttributeName: UIFont.italicSystemFontOfSize(40), NSForegroundColorAttributeName: UIColor.purpleColor()]))
attr.appendAttributedString(NSAttributedString(string: "DEPENDS UPON", attributes: [NSFontAttributeName: UIFont.boldSystemFontOfSize(15), NSForegroundColorAttributeName: UIColor.brownColor()]))
label.attributedText = attr
关于ios - 如何使用核心文本在ios中的不同UIlabel文本行上设置不同的字体样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38388667/