Assign multiple attributes in one go rather than one at a time

This commit is contained in:
Nate Weaver 2020-04-16 15:38:27 -05:00
parent df4ea1479a
commit 26415f0c62
1 changed files with 7 additions and 2 deletions

View File

@ -101,8 +101,13 @@ extension NSAttributedString {
let descriptor = font.fontDescriptor.addingAttributes(attributes)
let newFont = Font(descriptor: descriptor, size: font.pointSize)
mutable.addAttribute(.font, value: newFont as Any, range: range)
mutable.addAttribute(superscriptAttribute, value: 0, range: range)
let newAttributes: [NSAttributedString.Key: Any] = [
.font: newFont as Any,
superscriptAttribute: 0,
]
mutable.addAttributes(newAttributes, range: range)
}
}