updated for textcolor
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
2394055815
commit
9aad50fb0b
@ -27,14 +27,14 @@ public struct TextStyleLabelAttribute: LabelAttributeModel {
|
||||
public var location: Int
|
||||
public var length: Int
|
||||
public var textStyle: TextStyle
|
||||
public var textColor: UIColor
|
||||
public var textColor: UIColor?
|
||||
public var textPosition: TextPosition
|
||||
public var lineBreakMode: NSLineBreakMode
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Initializer
|
||||
//--------------------------------------------------
|
||||
public init(location: Int, length: Int, textStyle: TextStyle, textColor: UIColor = .black, textPosition: TextPosition = .left, lineBreakMode: NSLineBreakMode = .byWordWrapping) {
|
||||
public init(location: Int, length: Int, textStyle: TextStyle, textColor: UIColor? = nil, textPosition: TextPosition = .left, lineBreakMode: NSLineBreakMode = .byWordWrapping) {
|
||||
self.location = location
|
||||
self.length = length
|
||||
self.textStyle = textStyle
|
||||
@ -45,9 +45,11 @@ public struct TextStyleLabelAttribute: LabelAttributeModel {
|
||||
|
||||
public func setAttribute(on attributedString: NSMutableAttributedString) {
|
||||
attributedString.removeAttribute(.font, range: range)
|
||||
attributedString.removeAttribute(.foregroundColor, range: range)
|
||||
attributedString.addAttribute(.font, value: textStyle.font, range: range)
|
||||
attributedString.addAttribute(.foregroundColor, value: textColor, range: range)
|
||||
if let textColor {
|
||||
attributedString.removeAttribute(.foregroundColor, range: range)
|
||||
attributedString.addAttribute(.foregroundColor, value: textColor, range: range)
|
||||
}
|
||||
setStyleAttributes(attributedString)
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user