TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | Apache 2 |
ReleasedLast Release | Feb 2018 |
SwiftSwift Version | 4.0 |
SPMSupports SPM | ✗ |
Maintained by Nikita Kazakov.
An extension to NSAttributedString for creating attributed strings by using a
given format string.
Use with attributes to set attributes for the entire string
NSAttributedString.attributedStringWith(attributes: [NSAttributedStringKey : Any], format: NSString, arguments: NSAttributedString...)
Use without attributes to set attributes only for arguments
NSAttributedString.attributedStringWith(format: NSString, arguments: NSAttributedString...)
To run the example project, clone the repo, and run pod install
from the Example directory first.
one = NSAttributedString(string: "one", attributes: [
NSAttributedStringKey.font: UIFont.boldSystemFont(ofSize: 23),
NSAttributedStringKey.foregroundColor: UIColor.blue
])
two = NSAttributedString(string: "two", attributes: [
NSAttributedStringKey.font: UIFont.boldSystemFont(ofSize: 23),
NSAttributedStringKey.foregroundColor: UIColor.green
])
three = NSAttributedString(string: "three", attributes: [
NSAttributedStringKey.font: UIFont.boldSystemFont(ofSize: 23),
NSAttributedStringKey.foregroundColor: UIColor.red
])
etc = NSAttributedString(string: "etc", attributes: [
NSAttributedStringKey.font: UIFont.boldSystemFont(ofSize: 23),
NSAttributedStringKey.foregroundColor: UIColor.gray
])
result = NSAttributedString.attributedStringWith(format: "You can multiple (%@, %@, %@, %@) arguments with their attributes each of them", arguments: one, two, three, etc)
MAGNSAttributedStringFormat is available through CocoaPods. To install
it, simply add the following line to your Podfile:
pod 'MAGNSAttributedStringFormat'
Nikita Kazakov, [email protected]
MAGNSAttributedStringFormat is available under the MIT license. See the LICENSE file for more info.