@@ -11,15 +11,15 @@ import Foundation
11
11
private struct SubstringAttribute {
12
12
13
13
let substring : String
14
- let attribute : String
15
- let value : AnyObject
14
+ let attribute : NSAttributedStringKey
15
+ let value : Any
16
16
}
17
17
18
18
private struct RangeAttribute {
19
19
20
20
let range : NSRange
21
- let attribute : String
22
- let value : AnyObject
21
+ let attribute : NSAttributedStringKey
22
+ let value : Any
23
23
}
24
24
25
25
open class NSAttributedStringBuilder : NSObject {
@@ -90,19 +90,19 @@ open class NSAttributedStringBuilder: NSObject {
90
90
@objc ( setFont: onSubstring: )
91
91
open func set( font: UIFont ? , onSubstring substring: String ? ) -> NSAttributedStringBuilder {
92
92
93
- return self . set ( attribute: NSFontAttributeName , value: font, onSubstring: substring)
93
+ return self . set ( attribute: NSAttributedStringKey . font , value: font, onSubstring: substring)
94
94
}
95
95
96
96
@discardableResult
97
97
@objc ( setTextColor: onSubstring: )
98
98
open func set( textColor color: UIColor ? , onSubstring substring: String ? ) -> NSAttributedStringBuilder {
99
99
100
- return self . set ( attribute: NSForegroundColorAttributeName , value: color, onSubstring: substring)
100
+ return self . set ( attribute: NSAttributedStringKey . foregroundColor , value: color, onSubstring: substring)
101
101
}
102
102
103
103
@discardableResult
104
104
@objc ( setAttribute: value: onSubstring: )
105
- open func set( attribute: String ? , value: AnyObject ? , onSubstring substring: String ? ) -> NSAttributedStringBuilder {
105
+ open func set( attribute: NSAttributedStringKey ? , value: Any ? , onSubstring substring: String ? ) -> NSAttributedStringBuilder {
106
106
107
107
if let attribute = attribute, let value = value, let substring = substring {
108
108
@@ -121,7 +121,7 @@ open class NSAttributedStringBuilder: NSObject {
121
121
122
122
@discardableResult
123
123
@objc ( setAttribute: value: onRange: )
124
- open func set( attribute: String ? , value: AnyObject ? , onRange range: NSRange ) -> NSAttributedStringBuilder {
124
+ open func set( attribute: NSAttributedStringKey ? , value: Any ? , onRange range: NSRange ) -> NSAttributedStringBuilder {
125
125
126
126
if let attribute = attribute, let value = value {
127
127
@@ -151,17 +151,17 @@ private extension NSAttributedStringBuilder {
151
151
152
152
if let textColor = self . textColor {
153
153
154
- attributedString. addAttribute ( NSForegroundColorAttributeName , value: textColor, range: fullRange)
154
+ attributedString. addAttribute ( NSAttributedStringKey . foregroundColor , value: textColor, range: fullRange)
155
155
}
156
156
157
157
if let textFont = self . textFont {
158
158
159
- attributedString. addAttribute ( NSFontAttributeName , value: textFont, range: fullRange)
159
+ attributedString. addAttribute ( NSAttributedStringKey . font , value: textFont, range: fullRange)
160
160
}
161
161
162
162
if let fontTracking = self . fontTracking {
163
163
164
- attributedString. addAttribute ( NSKernAttributeName , value: fontTracking, range: fullRange)
164
+ attributedString. addAttribute ( NSAttributedStringKey . kern , value: fontTracking, range: fullRange)
165
165
}
166
166
167
167
var paragraphStyle : NSMutableParagraphStyle ?
@@ -184,7 +184,7 @@ private extension NSAttributedStringBuilder {
184
184
185
185
if let paragraphStyle = paragraphStyle {
186
186
187
- attributedString. addAttribute ( NSParagraphStyleAttributeName , value: paragraphStyle, range: fullRange)
187
+ attributedString. addAttribute ( NSAttributedStringKey . paragraphStyle , value: paragraphStyle, range: fullRange)
188
188
}
189
189
190
190
if let substringAttributes = self . substringAttributes {
0 commit comments