NSMutableAttributedString
extension NSMutableAttributedString
-
Modifies this instance of the string to remove characters from a given character set from the beginning and end of the string.
See http://panupan.com/2012/06/04/trim-leading-and-trailing-whitespaces-from-nsmutableattributedstring/
Declaration
Swift
public func trimCharacters(in set: CharacterSet)Parameters
charSetThe character set with which to remove characters.
-
Applies a font to the entire string.
Declaration
Swift
@discardableResult public func font(_ font: UIFont) -> SelfParameters
fontThe font.
-
Applies a font to the entire string.
Note: If the specified font name cannot be loaded, this method will fallback to the system font at the specified size.
Declaration
Swift
@discardableResult public func font(name: String, size: CGFloat) -> SelfParameters
nameThe font name.
sizeThe font size.
-
Applies a text alignment to the entire string.
Declaration
Swift
@discardableResult public func alignment(_ alignment: NSTextAlignment) -> SelfParameters
alignmentThe text alignment.
-
Applies line spacing to the entire string.
Declaration
Swift
@discardableResult public func lineSpacing(_ lineSpacing: CGFloat) -> SelfParameters
lineSpacingThe line spacing amount.
-
Applies paragraph spacing to the entire string.
Declaration
Swift
@discardableResult public func paragraphSpacing(_ paragraphSpacing: CGFloat) -> SelfParameters
paragraphSpacingThe paragraph spacing amount.
-
Applies a line break mode to the entire string.
Declaration
Swift
@discardableResult public func lineBreak(_ mode: NSLineBreakMode) -> SelfParameters
modeThe line break mode.
-
Applies a line height multiplier to the entire string.
Declaration
Swift
@discardableResult public func lineHeight(multiple: CGFloat) -> SelfParameters
multipleThe line height multiplier.
-
Applies a first line head indent to the string.
Declaration
Swift
@discardableResult public func firstLineHeadIndent(_ indent: CGFloat) -> SelfParameters
indentThe first line head indent amount.
-
Applies a head indent to the string.
Declaration
Swift
@discardableResult public func headIndent(_ indent: CGFloat) -> SelfParameters
indentThe head indent amount.
-
Applies a tail indent to the string.
Declaration
Swift
@discardableResult public func tailIndent(_ indent: CGFloat) -> SelfParameters
indentThe tail indent amount.
-
Applies a minimum line height to the entire string.
Declaration
Swift
@discardableResult public func minimumLineHeight(_ height: CGFloat) -> SelfParameters
heightThe minimum line height.
-
Applies a maximum line height to the entire string.
Declaration
Swift
@discardableResult public func maximumLineHeight(_ height: CGFloat) -> SelfParameters
heightThe maximum line height.
-
Applies a base writing direction to the entire string.
Declaration
Swift
@discardableResult public func baseWritingDirection(_ direction: NSWritingDirection) -> SelfParameters
directionThe base writing direction.
-
Applies a paragraph spacing before amount to the string.
Declaration
Swift
@discardableResult public func paragraphSpacingBefore(_ spacing: CGFloat) -> SelfParameters
spacingThe distance between the paragraph’s top and the beginning of its text content.
-
Applies the given color over the entire string, as the foreground color.
Declaration
Swift
@discardableResult @nonobjc public func color(_ color: UIColor, alpha: CGFloat = 1) -> SelfParameters
colorThe color to apply.
-
Applies the given color over the entire string, as the foreground color.
Declaration
Swift
@discardableResult public func color(red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat = 1) -> SelfParameters
colorThe color to apply.
-
Applies the given color over the entire string, as the foreground color.
Declaration
Swift
@discardableResult public func color(white: CGFloat, alpha: CGFloat = 1) -> SelfParameters
colorThe color to apply.
-
Applies the given color over the entire string, as the foreground color.
Declaration
Swift
@discardableResult @nonobjc public func color(_ hex: UInt32, alpha: CGFloat = 1) -> SelfParameters
colorThe color to apply.
-
Applies a single underline under the entire string.
Declaration
Swift
@discardableResult public func underline(style: NSUnderlineStyle = .single, color: UIColor? = nil) -> SelfParameters
styleThe
NSUnderlineStyleto apply. Defaults to.styleSingle. -
Applies a kern (spacing) value to the entire string.
Declaration
Swift
@discardableResult public func kern(_ value: CGFloat) -> SelfParameters
valueThe space between each character in the string.
-
Applies a strikethrough to the entire string.
Declaration
Swift
@discardableResult public func strikethrough(style: NSUnderlineStyle = .single, color: UIColor? = nil) -> SelfParameters
styleThe
NSUnderlineStyleto apply. Defaults to.styleSingle.colorThe underline color. Defaults to the color of the text.
-
Applies a stroke to the entire string.
Declaration
Swift
@discardableResult public func stroke(color: UIColor, width: CGFloat) -> SelfParameters
colorThe stroke color.
widthThe stroke width.
-
Applies a shadow to the entire string.
Declaration
Swift
@discardableResult public func shadow(color: UIColor, radius: CGFloat, offset: CGSize) -> SelfParameters
colorThe shadow color.
radiusThe shadow blur radius.
offsetThe shadow offset.
-
Applies a background color to the entire string.
Declaration
Swift
@discardableResult @nonobjc public func backgroundColor(_ color: UIColor, alpha: CGFloat = 1) -> SelfParameters
colorThe color to apply.
-
Applies a background color to the entire string.
Declaration
Swift
@discardableResult public func backgroundColor(red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat = 1) -> SelfParameters
redThe red color component.
greenThe green color component.
blueThe blue color component.
alphaThe alpha component.
-
Applies a background color to the entire string.
Declaration
Swift
@discardableResult public func backgroundColor(white: CGFloat, alpha: CGFloat = 1) -> SelfParameters
whiteThe white color component.
alphaThe alpha component.
-
Applies a background color to the entire string.
Declaration
Swift
@discardableResult @nonobjc public func backgroundColor(_ hex: UInt32, alpha: CGFloat = 1) -> SelfParameters
hexThe hex color value.
alphaThe alpha component.
-
Applies a baseline offset to the entire string.
Declaration
Swift
@discardableResult public func baselineOffset(_ offset: Float) -> SelfParameters
offsetThe offset value.
View on GitHub
Install in Dash
NSMutableAttributedString Extension Reference