| | |
| | | return AttributedStringbuilder() |
| | | } |
| | | |
| | | @discardableResult |
| | | func add(string: String,withFont: UIFont,withColor: UIColor,lineSpace: CGFloat) -> AttributedStringbuilder { |
| | | let style = NSMutableParagraphStyle() |
| | | style.lineSpacing = lineSpace |
| | | mutableAttributedString.append(NSAttributedString(string: string, attributes: [NSAttributedString.Key.foregroundColor: withColor,NSAttributedString.Key.font: withFont, NSAttributedString.Key.paragraphStyle: style])) |
| | | return self |
| | | } |
| | | |
| | | @discardableResult |
| | | func add(string: String,withFont: UIFont,withColor: UIColor,backColor: UIColor) -> AttributedStringbuilder { |
| | | let style = NSMutableParagraphStyle() |
| | | mutableAttributedString.append(NSAttributedString(string: string, attributes: [NSAttributedString.Key.foregroundColor: withColor,NSAttributedString.Key.font: withFont,NSAttributedString.Key.backgroundColor: backColor, NSAttributedString.Key.paragraphStyle: style])) |
| | | return self |
| | | } |
| | | |
| | | @discardableResult |
| | | func add(string: String,withFont: UIFont,withColor: UIColor,indent: CGFloat) -> AttributedStringbuilder { |
| | | let style = NSMutableParagraphStyle() |
| | | style.firstLineHeadIndent = indent |
| | |
| | | return self |
| | | } |
| | | |
| | | @discardableResult |
| | | func add(string: String,withFont: UIFont,withColor: UIColor,indent: CGFloat,lineSpace: CGFloat) -> AttributedStringbuilder { |
| | | let style = NSMutableParagraphStyle() |
| | | style.firstLineHeadIndent = indent |
| | |
| | | return self |
| | | } |
| | | |
| | | @discardableResult |
| | | func underLine() -> AttributedStringbuilder { |
| | | let range1 = NSRange(location: 0, length: mutableAttributedString.string.count) |
| | | let number = NSNumber(value:NSUnderlineStyle.single.rawValue) |
| | |
| | | return self |
| | | } |
| | | |
| | | @discardableResult |
| | | func add(string: String,withFont: UIFont,withColor: UIColor) -> AttributedStringbuilder { |
| | | mutableAttributedString.append(NSAttributedString(string: string, attributes: [NSAttributedString.Key.foregroundColor: withColor,NSAttributedString.Key.font: withFont])) |
| | | return self |
| | | } |
| | | |
| | | |
| | | |
| | | @discardableResult |
| | | func add(string: String,withSize: CGFloat,withColor: UIColor) -> AttributedStringbuilder { |
| | | mutableAttributedString.append(NSAttributedString(string: string, attributes: [NSAttributedString.Key.foregroundColor: withColor,NSAttributedString.Key.font: UIFont.systemFont(ofSize: withSize)])) |
| | | return self |
| | | } |
| | | |
| | | @discardableResult |
| | | func attach(attachment: NSTextAttachment) -> AttributedStringbuilder { |
| | | mutableAttributedString.append(NSAttributedString(attachment: attachment)) |
| | | return self |
| | | } |
| | | |
| | | @discardableResult |
| | | func attach(image: UIImage) -> AttributedStringbuilder { |
| | | let attachment = NSTextAttachment() |
| | | attachment.image = image |