基于Swift插值方式优雅的构建富文本, 支持点击长按事件, 支持不同类型过滤, 支持自定义视图等.
移除wacth demo
ASAttributedString.Attribute
add:
// currency
public static func custom(_ value: [NSAttributedString.Key: Any])
// macOS
public static func cursor(_ value: NSCursor)
public static func markedClauseSegment(_ value: Int)
public static func spellingState(_ value: SpellingState)
public static func superscript(_ value: Int)
public static func textAlternatives(_ value: NSTextAlternatives)
public static func toolTip(_ value: String)
ASAttributedString.Attribute.ParagraphStyle
add:
@available(macOS 12.0, iOS 15.0, tvOS 15.0, watchOSApplicationExtension 8.0, *)
public static func usesDefaultHyphenation(_ value: Bool)
public static func lineBreakStrategy(_ value: NSParagraphStyle.LineBreakStrategy)
// ASAttributedString.AsyncImageAttachment
textView.attributed.text = """
\(.image(url, placeholder: xxxxx))
"""
Custom loader:
ASAttributedString.AsyncImageAttachment.Loader = AsyncImageAttachmentKingfisherLoader.self
Please read the demo AttachmentViewController.swift
file for details.
var string = ASAttributedString("XXX")
string.add(attributes: [.foreground(.red)], range: .init(location: 0, length: string.length))
string.set(attributes: [.foreground(.red)], range: .init(location: 0, length: string.length))
label.attributed.text = string
equal
label.attributed.text = ASAttributedString("XXX").add(attributes: .foreground(.red)).set(attributes: .foreground(.red))