EasyText
EasyText copied to clipboard
Easy way to create a NSAttributedString in Swift 5
EasyText
EasyText is library written in Swift, which provide an easy and safe way to create a NSAttributedString.It use StringInterpolation in Swift 5.
Features
- [x] Type safe
- [x] Support multiple platfoms, iOS and macOS
- [x] Support most of
NSAttributedString.Key - [x] Support usual operators, such as
+,+= - [x] 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, [email protected]
License
EasyText is available under the MIT license. See the LICENSE file for more info.