AttributedString Versions Save

基于Swift插值方式优雅的构建富文本, 支持点击长按事件, 支持不同类型过滤, 支持自定义视图等.

3.4.1

2 weeks ago

3.4.0

3 weeks ago

3.3.5

1 year ago

3.3.4

1 year ago

3.3.3

1 year ago

移除wacth demo

3.3.2

1 year ago

3.3.1

1 year ago

3.3.0

2 years ago

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)

3.2.0

2 years ago

Attachment Async Image: (Only supports iOS: UITextView)

// 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.

3.1.0

2 years ago
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))