Skip to content

Commit 5801087

Browse files
committed
version 3.1.0 补充属性设置方式
1 parent 6f3c892 commit 5801087

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

AttributedString.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22

33
s.name = "AttributedString"
4-
s.version = "3.0.1"
4+
s.version = "3.1.0"
55
s.summary = "基于Swift字符串插值快速构建你想要的富文本, 支持点击按住等事件获取, 支持多种类型过滤"
66

77
s.homepage = "https://github.com/lixiang1994/AttributedString"

Sources/AttributedString.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public typealias Font = UIFont
2424
#endif
2525

2626
public struct ASAttributedString {
27+
2728
internal init(value: NSAttributedString) {
2829
self.value = value
2930
}
@@ -204,6 +205,29 @@ extension ASAttributedString {
204205
}
205206
}
206207

208+
extension ASAttributedString {
209+
210+
public func add(attributes: Attribute..., range: NSRange? = .none) -> Self {
211+
return add(attributes, range: range ?? .init(location: 0, length: length))
212+
}
213+
214+
public func add(_ attributes: [Attribute], range: NSRange) -> Self {
215+
var temp = self
216+
temp.add(attributes: attributes, range: range)
217+
return temp
218+
}
219+
220+
public func set(attributes: Attribute..., range: NSRange? = .none) -> Self {
221+
return set(attributes, range: range ?? .init(location: 0, length: length))
222+
}
223+
224+
public func set(_ attributes: [Attribute], range: NSRange) -> Self {
225+
var temp = self
226+
temp.set(attributes: attributes, range: range)
227+
return temp
228+
}
229+
}
230+
207231
fileprivate extension Dictionary where Key == NSAttributedString.Key, Value == Any {
208232

209233
static func == (lhs: [NSAttributedString.Key: Any], rhs: [NSAttributedString.Key: Any]) -> Bool {

0 commit comments

Comments
 (0)