NSAttributedString
public extension NSAttributedString
AttributedString+Mutable provides the ability to modify an attributed string.
Version
1.9.0Date
29/04/2022-
Append a new attributed string to the end of the current one.
Declaration
Swift
func appending(_ string: NSAttributedString) -> NSAttributedStringParameters
stringThe new attributed string.
Return Value
The combined string
-
Add an underline to a substring.
Declaration
Swift
func addingUnderline(toFirstSubstring substring: String? = nil) -> NSAttributedStringParameters
substringThe substring that should have an underline. Nil will apply the line to the whole string.
Return Value
A string with an underline.
-
Add linking function to a substring.
Declaration
Swift
func addingLink(_ link: String, toFirstSubstring substring: String? = nil) -> NSAttributedStringParameters
linkThe url link to be applied.
substringThe clickable substring. Nil will apply the link to the whole string.
Return Value
A string with a link.
-
Change the font of a substring.
Declaration
Swift
func changingFont(_ font: UIFont, ofFirstSubstring substring: String? = nil) -> NSAttributedStringParameters
fontThe new font to be applied.
substringThe substring that should be changed. Nil will apply the new font to the whole string.
Return Value
A string with part of the string applying the new font.
-
Strike cross part of the string.
Declaration
Swift
func addingStrike(ofFirstSubstring substring: String? = nil) -> NSAttributedStringParameters
substringThe substring that should be crossed. Nil will apply the effect to the whole string.
Return Value
A string with part of it being crossed.
-
Change the color of a sub string.
Declaration
Swift
func changingColor(_ color: UIColor, ofFirstSubstring substring: String? = nil) -> NSAttributedStringParameters
colorThe new color to apply.
substringThe substring that should apply the new color. Nil will apply the color to the whole string.
Return Value
A new string with part of it using the new color.
-
Change the letter spacing of a sub string.
Declaration
Swift
func changingLetterSpacing(_ letterSpacing: CGFloat, ofFirstSubstring substring: String? = nil) -> NSAttributedStringParameters
letterSpacingThe space between letters.
substringThe substring that should apply the new letter spacing. Nil will apply the letter spacing to the whole string.
Return Value
A new string with part of it using the new color.
NSAttributedString Extension Reference