From 0d8f5fc8a516bfd07e425909e4a4432600572ee7 Mon Sep 17 00:00:00 2001 From: younger_times <841720330@qq.com> Date: 星期三, 05 七月 2023 21:21:35 +0800 Subject: [PATCH] 修复BUG --- OKProject/Extension/AttributedStringbuilder.swift | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-) diff --git a/OKProject/Extension/AttributedStringbuilder.swift b/OKProject/Extension/AttributedStringbuilder.swift index 4cf52be..2e376c3 100644 --- a/OKProject/Extension/AttributedStringbuilder.swift +++ b/OKProject/Extension/AttributedStringbuilder.swift @@ -16,18 +16,22 @@ 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 @@ -35,6 +39,7 @@ return self } + @discardableResult func add(string: String,withFont: UIFont,withColor: UIColor,indent: CGFloat,lineSpace: CGFloat) -> AttributedStringbuilder { let style = NSMutableParagraphStyle() style.firstLineHeadIndent = indent @@ -43,6 +48,7 @@ return self } + @discardableResult func underLine() -> AttributedStringbuilder { let range1 = NSRange(location: 0, length: mutableAttributedString.string.count) let number = NSNumber(value:NSUnderlineStyle.single.rawValue) @@ -50,23 +56,25 @@ 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 -- Gitblit v1.7.1