在我的应用程序中,我正在使用ActiveLabel
fram Github.
在这种情况下,我的标签不会显示UILabel中间的文本.如果我使用普通的UILabel它可以正常工作,但是当它设置为ActiveLabel时,它会像这样.
(图像在运行时拍摄)
我认为这是以某种方式使用对齐的代码:
/// add line break mode private func addLineBreak(attrString: NSAttributedString) -> NSMutableAttributedString { let mutAttrString = NSMutableAttributedString(attributedString: attrString) var range = NSRange(location: 0, length: 0) var attributes = mutAttrString.attributesAtIndex(0, effectiveRange: &range) let paragraphStyle = attributes[NSParagraphStyleAttributeName] as? NSMutableParagraphStyle ?? NSMutableParagraphStyle() paragraphStyle.lineBreakMode = NSLineBreakMode.ByWordWrapping if let lineSpacing = lineSpacing { paragraphStyle.lineSpacing = CGFloat(lineSpacing) } attributes[NSParagraphStyleAttributeName] = paragraphStyle mutAttrString.setAttributes(attributes, range: range) return mutAttrString }
ActiveLabel.swift
ActiveType.swift
任何想法如何我可以在中间这样做:
(图片取自故事板)