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)? {
|
static func createAttributeModelFor(key: NSAttributedString.Key, range: NSRange, value: Any) -> (any LabelAttributeModel)? {
|
||||||
switch key {
|
guard let value = value as? AnyHashable else { return nil }
|
||||||
case NSAttributedString.Key.font:
|
return AnyAttribute(location: range.location, length: range.length, key: key, value: value)
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user