/EasyText

Easy way to create a NSAttributedString in Swift 5

Primary LanguageSwiftMIT LicenseMIT

EasyText

CI Status Version License Platform

EasyText is library written in Swift, which provide an easy and safe way to create a NSAttributedString.It use StringInterpolation in Swift 5.

Features

  • Type safe
  • Support multiple platfoms, iOS and macOS
  • Support most of NSAttributedString.Key
  • Support usual operators, such as +,+=
  • Support UIImage/NSImage

Example

let text:EasyText = "\("font is 30 pt and color is yellow", .font(.systemFont(ofSize: 20)), .color(.blue))"

textView.attributedText = text.attributedString

More examples in Example/iOS.

Requirements

  • iOS 9.0+/macOS 10.11+

  • Swift 5.0+

Installation

Cocoapods

pod 'EasyText','~> 1.0.0'

Carthage

github "Nemocdz/EasyText" "1.0.0"

Swift Package Manager

dependencies: [
    .package(url: "https://github.com/Nemocdz/EasyText.git", from: "1.0.0")
]

Article

使用 Swift 5 字符串插值快速构建 AttributeString

Author

Nemocdz, nemocdz@gmail.com

License

EasyText is available under the MIT license. See the LICENSE file for more info.