UILabel
extension UILabel: SkeletonViewDataSource
UILabel骨架屏视图数据源扩展
-
Declaration
Swift
open func skeletonViewProvider() -> SkeletonView?
-
快速设置attributedText样式,设置后调用setText:会自动转发到setAttributedText:方法
Declaration
Swift
public var fw_textAttributes: [NSAttributedString.Key : Any]? { get set }
-
快速设置文字的行高,优先级低于fwTextAttributes,设置后调用setText:会自动转发到setAttributedText:方法。小于等于0时恢复默认行高
Declaration
Swift
public var fw_lineHeight: CGFloat { get set }
-
自定义内容边距,未设置时为系统默认。当内容为空时不参与intrinsicContentSize和sizeThatFits:计算,方便自动布局
Declaration
Swift
public var fw_contentInset: UIEdgeInsets { get set }
-
纵向分布方式,默认居中
Declaration
Swift
public var fw_verticalAlignment: UIControl.ContentVerticalAlignment { get set }
-
添加点击手势并自动识别NSLinkAttributeName|URL属性,点击高亮时回调链接,点击其它区域回调nil
Declaration
Swift
public func fw_addLinkGesture(block: @escaping (Any?) -> Void)
-
获取手势触发位置的文本属性,可实现行内点击效果等,allowsSpacing默认为NO空白处不可点击。为了识别更准确,attributedText需指定font
Declaration
Swift
public func fw_attributes( gesture: UIGestureRecognizer, allowsSpacing: Bool ) -> [NSAttributedString.Key: Any]
-
快速设置标签并指定文本
Declaration
Swift
public func fw_setFont( _ font: UIFont?, textColor: UIColor?, text: String? = nil, textAlignment: NSTextAlignment? = nil, numberOfLines: Int? = nil, lineHeight: CGFloat? = nil )
-
快速创建标签并指定文本
Declaration
Swift
public static func fw_label( font: UIFont?, textColor: UIColor?, text: String? = nil, textAlignment: NSTextAlignment? = nil, numberOfLines: Int? = nil, lineHeight: CGFloat? = nil ) -> Self
-
自适应字体大小,可设置缩放因子等
Declaration
Swift
public func fw_adjustsFontSize( minimumScaleFactor: CGFloat? = nil, baselineAdjustment: UIBaselineAdjustment? = nil )
-
获取当前标签是否非空,兼容attributedText|text
Declaration
Swift
public var fw_isNotEmpty: Bool { get }
-
计算当前标签实际显示行数,兼容contentInset|lineHeight
Declaration
Swift
public var fw_actualNumberOfLines: Int { get }
-
计算指定边界、内边距、行高、行数时,当前标签实际显示行数
Declaration
Swift
public func fw_actualNumberOfLines(drawSize: CGSize, contentInset: UIEdgeInsets? = nil, lineHeight: CGFloat? = nil, numberOfLines: Int? = nil) -> Int
-
计算当前文本所占尺寸,需frame或者宽度布局完整
Declaration
Swift
public var fw_textSize: CGSize { get }
-
计算指定边界时,当前文本所占尺寸
Declaration
Swift
public func fw_textSize(drawSize: CGSize, contentInset: UIEdgeInsets? = nil) -> CGSize
-
计算当前属性文本所占尺寸,需frame或者宽度布局完整,attributedText需指定字体
Declaration
Swift
public var fw_attributedTextSize: CGSize { get }
-
计算指定边界时,当前属性文本所占尺寸,attributedText需指定字体
Declaration
Swift
public func fw_attributedTextSize(drawSize: CGSize, contentInset: UIEdgeInsets? = nil) -> CGSize