Slide 20
Slide 20 text
AttributedStringを便利に
extension String {
func attribute(
ranges: [String],
keyPath: WritableKeyPath,
value: Value
) -> AttributedString {
ranges.reduce(AttributedString(self)) { attributedString, element in
attributedString.attribute(range: element, keyPath: keyPath, value: value)
}
}
}