Updated Deprecated LabelWithInternalButton message. Improved layout of LeftRightLabelView.
This commit is contained in:
parent
e8ab746351
commit
9fb4c099b2
@ -14,7 +14,7 @@ public typealias ButtonObjectDelegate = NSObjectProtocol & ButtonDelegateProtoco
|
||||
public typealias CoreObjectActionLoadPresentDelegate = MVMCoreActionDelegateProtocol & MVMCoreLoadDelegateProtocol & MVMCorePresentationDelegateProtocol & NSObjectProtocol
|
||||
|
||||
|
||||
@available(*, deprecated, message: "This class is deprecated, please use the Label class.")
|
||||
@available(*, deprecated, message: "Use Label instead.")
|
||||
@objcMembers open class LabelWithInternalButton: UIControl, MVMCoreViewProtocol, MFButtonProtocol, MVMCoreUIMoleculeViewProtocol {
|
||||
//------------------------------------------------------
|
||||
// MARK: - Properties
|
||||
|
||||
@ -26,14 +26,6 @@ import Foundation
|
||||
|
||||
var rightTextLabelLeading: NSLayoutConstraint?
|
||||
|
||||
//------------------------------------------------------
|
||||
// MARK: - Properties
|
||||
//------------------------------------------------------
|
||||
|
||||
var leftRightMarginsValue: CGFloat {
|
||||
return layoutMargins.left + layoutMargins.right
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
// MARK: - Initialization
|
||||
//------------------------------------------------------
|
||||
@ -80,7 +72,7 @@ import Foundation
|
||||
rightTextLabel.updateView(size)
|
||||
|
||||
if leftTextLabel.hasText && rightTextLabel.hasText {
|
||||
rightTextLabel.preferredMaxLayoutWidth = (size - leftRightMarginsValue) * 0.4
|
||||
rightTextLabel.preferredMaxLayoutWidth = floor((size - 16) * 0.4)
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,16 +105,16 @@ import Foundation
|
||||
|
||||
bottomAnchor.constraint(greaterThanOrEqualTo: rightTextLabel.bottomAnchor).isActive = true
|
||||
|
||||
leftTextWidth = leftTextLabel.widthAnchor.constraint(greaterThanOrEqualTo: widthAnchor, multiplier: 0.6, constant: -leftRightMarginsValue)
|
||||
leftTextWidth = leftTextLabel.widthAnchor.constraint(greaterThanOrEqualTo: layoutMarginsGuide.widthAnchor, multiplier: 0.6)
|
||||
leftTextWidth?.priority = UILayoutPriority(rawValue: 995)
|
||||
leftTextWidth?.isActive = true
|
||||
|
||||
rightTextWidth = rightTextLabel.widthAnchor.constraint(lessThanOrEqualTo: widthAnchor, multiplier: 0.4, constant: -leftRightMarginsValue)
|
||||
rightTextWidth = rightTextLabel.widthAnchor.constraint(lessThanOrEqualTo: layoutMarginsGuide.widthAnchor, multiplier: 0.4)
|
||||
rightTextWidth?.priority = UILayoutPriority(rawValue: 906)
|
||||
rightTextWidth?.isActive = true
|
||||
|
||||
leftTextLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 900), for: .horizontal)
|
||||
rightTextLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 901), for: .horizontal)
|
||||
leftTextLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 901), for: .horizontal)
|
||||
rightTextLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 902), for: .horizontal)
|
||||
|
||||
leftTextLabel.setContentHuggingPriority(.required, for: .vertical)
|
||||
rightTextLabel.setContentHuggingPriority(.required, for: .vertical)
|
||||
@ -137,7 +129,7 @@ import Foundation
|
||||
rightTextLabelLeading?.isActive = false
|
||||
layoutMarginsGuide.trailingAnchor.constraint(equalTo: leftTextLabel.trailingAnchor).isActive = true
|
||||
leftTextWidth?.isActive = false
|
||||
leftTextWidth = leftTextLabel.widthAnchor.constraint(equalTo: widthAnchor, multiplier: 1.0, constant: -leftRightMarginsValue)
|
||||
leftTextWidth = leftTextLabel.widthAnchor.constraint(equalTo: layoutMarginsGuide.widthAnchor, multiplier: 1.0)
|
||||
leftTextWidth?.priority = UILayoutPriority(rawValue: 999)
|
||||
leftTextWidth?.isActive = true
|
||||
}
|
||||
@ -146,9 +138,9 @@ import Foundation
|
||||
|
||||
rightTextLabelLeading?.isActive = false
|
||||
rightTextLabel.trailingAnchor.constraint(equalTo: layoutMarginsGuide.trailingAnchor).isActive = true
|
||||
layoutMarginsGuide.leadingAnchor.constraint(equalTo: rightTextLabel.leadingAnchor).isActive = true
|
||||
rightTextLabel.leadingAnchor.constraint(equalTo: layoutMarginsGuide.leadingAnchor).isActive = true
|
||||
rightTextWidth?.isActive = false
|
||||
rightTextWidth = rightTextLabel.widthAnchor.constraint(equalTo: widthAnchor, multiplier: 1.0, constant: -leftRightMarginsValue)
|
||||
rightTextWidth = rightTextLabel.widthAnchor.constraint(equalTo: layoutMarginsGuide.widthAnchor, multiplier: 1.0)
|
||||
rightTextWidth?.priority = UILayoutPriority(rawValue: 999)
|
||||
rightTextWidth?.isActive = true
|
||||
}
|
||||
@ -183,8 +175,4 @@ import Foundation
|
||||
constrainLeftLabel()
|
||||
}
|
||||
}
|
||||
|
||||
open override func needsToBeConstrained() -> Bool {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user