Merge branch 'release/11_4_0' into 'develop'
fixed issue with attributedText setting not working correctly See merge request BPHV_MIPS/vds_ios!177
This commit is contained in:
commit
4abcc313cf
@ -135,20 +135,18 @@ open class Label: UILabel, ViewProtocol, UserInfoable {
|
|||||||
/// Text that will be used in the label.
|
/// Text that will be used in the label.
|
||||||
private var _text: String!
|
private var _text: String!
|
||||||
override open var text: String! {
|
override open var text: String! {
|
||||||
get { _text }
|
didSet {
|
||||||
set {
|
_text = text
|
||||||
textSetMode = .text
|
textSetMode = .text
|
||||||
_text = newValue
|
setNeedsUpdate()
|
||||||
styleText(newValue)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///AttributedText that will be used in the label.
|
///AttributedText that will be used in the label.
|
||||||
override open var attributedText: NSAttributedString? {
|
override open var attributedText: NSAttributedString? {
|
||||||
get { super.attributedText }
|
didSet {
|
||||||
set {
|
|
||||||
textSetMode = .attributedText
|
textSetMode = .attributedText
|
||||||
styleAttributedText(newValue)
|
setNeedsUpdate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,7 +286,7 @@ open class Label: UILabel, ViewProtocol, UserInfoable {
|
|||||||
|
|
||||||
private func styleText(_ newValue: String!) {
|
private func styleText(_ newValue: String!) {
|
||||||
defer { invalidateIntrinsicContentSize() }
|
defer { invalidateIntrinsicContentSize() }
|
||||||
guard let newValue else {
|
guard let newValue, !newValue.isEmpty else {
|
||||||
// We don't need to use attributed text
|
// We don't need to use attributed text
|
||||||
super.attributedText = nil
|
super.attributedText = nil
|
||||||
super.text = newValue
|
super.text = newValue
|
||||||
@ -313,7 +311,7 @@ open class Label: UILabel, ViewProtocol, UserInfoable {
|
|||||||
|
|
||||||
private func styleAttributedText(_ newValue: NSAttributedString?) {
|
private func styleAttributedText(_ newValue: NSAttributedString?) {
|
||||||
defer { invalidateIntrinsicContentSize() }
|
defer { invalidateIntrinsicContentSize() }
|
||||||
guard let newValue = newValue else {
|
guard let newValue, !newValue.string.isEmpty else {
|
||||||
// We don't need any additional styling
|
// We don't need any additional styling
|
||||||
super.attributedText = newValue
|
super.attributedText = newValue
|
||||||
return
|
return
|
||||||
@ -424,3 +422,5 @@ open class Label: UILabel, ViewProtocol, UserInfoable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user