Super easy way to use NSMutableAttributedString.
Motivation of this project to make Attributed string super easy to use. This project save lots of time of developer while created attributed string.
Download source code and drag drop AttributedString folder into your project.
let text = "This is a colorful attributed string"
// Get NSMutableAttributedString
let attributedText = NSMutableAttributedString.getAttributedString(fromString: text)
//Apply red color on substring "This"
attributedText.apply(color: appRedColor, subString: "This")
//Apply yellow color on range
attributedText.apply(color: appYellowColor, onRange: NSMakeRange(5, 4))
let attributedText = NSMutableAttributedString.getAttributedString(fromString: text)
attributedText.apply(font: UIFont.boldSystemFont(ofSize: 24), subString: "This")
attributedText.apply(font: UIFont.italicSystemFont(ofSize: 20), subString: "string")
let text = "This is underline string"
let attributedText = NSMutableAttributedString.getAttributedString(fromString: text)
attributedText.underLine(subString: "This is underline string")
let text = "This is a strike and underline stroke string"
let attributedText = NSMutableAttributedString.getAttributedString(fromString: text)
attributedText.strikeThrough(thickness: 2, subString: "This is a")
attributedText.applyStroke(color: appRedColor, thickness: 2, subString: "stroke string")
let text = "This string is having a shadow"
let attributedText = NSMutableAttributedString.getAttributedString(fromString: text)
attributedText.applyShadow(shadowColor: .black, shadowWidth: 4.0, shadowHeigt: 4.0, shadowRadius: 4.0, subString: "This string is")
If string is having two same substring then use onRange functions instead of subString Example:
attributedText.apply(color: appYellowColor, onRange: NSMakeRange(5, 4))
iOSTechHub, [email protected]
Attributed is available under the MIT license. See the LICENSE file for more info.