refactored to use AnyLabelAttribute
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
eb48d8a807
commit
f9c8e328cf
@ -38,16 +38,7 @@ public extension NSAttributedString {
|
||||
}
|
||||
|
||||
static func createAttributeModelFor(key: NSAttributedString.Key, range: NSRange, value: Any) -> (any LabelAttributeModel)? {
|
||||
switch key {
|
||||
case NSAttributedString.Key.font:
|
||||
let value = value as! UIFont
|
||||
let style = TypographicalStyle.style(for: value.fontName, size: value.pointSize)
|
||||
return FontLabelAttribute(location: range.location, length: range.length, style: style)
|
||||
case NSAttributedString.Key.foregroundColor:
|
||||
return ColorLabelAttribute(location: range.location, length: range.length, color: value as! UIColor)
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
guard let value = value as? AnyHashable else { return nil }
|
||||
return AnyAttribute(location: range.location, length: range.length, key: key, value: value)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user