Closed HParis closed 2 years ago
其实你可以扩展实现 比如:
public extension Array where Element == ASAttributedString.Attribute {
static var defalut: [ASAttributedString.Attribute] = [
.font(.systemFont(ofSize: 13)),
.foreground(.black)
]
static let xxxx: [ASAttributedString.Attribute] = []
}
按照上面的扩展实现报错了。
\("test", with: .defalut)
但是这样的话,后面就无法在增加其他 attribute 属性了。
还是希望能实现这样的调用效果:
""" ("fontStyle: .sbuheadline", .fontStyle(.subheadline), .background(.systemBackground), .foreground(.label)) """
\("test", with: .defalut + [.kern(1), .xxxxx])
嗯嗯,好的。
谢谢!
我的需求是希望能自定义构造字符串差值过程中使用自定义的 attributes
但是目前由于 Attribute 的 attributes 是 internal 的,导致无法构造自定义的 attributes.