added label width and update anchor on right
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
a93edcc5ea
commit
efc15eabdf
@ -153,6 +153,10 @@ open class Toggle: Control, Changeable {
|
||||
let heightGreater = heightAnchor.constraint(greaterThanOrEqualToConstant: toggleContainerSize.height)
|
||||
heightGreater.priority = .defaultHigh
|
||||
|
||||
let labelWidth = label.widthAnchor.constraint(lessThanOrEqualToConstant: labelMaxWidth)
|
||||
labelWidth.priority = .required
|
||||
labelWidth.isActive = true
|
||||
|
||||
// Set up initial constraints for label and switch
|
||||
toggleView.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
|
||||
|
||||
@ -171,7 +175,7 @@ open class Toggle: Control, Changeable {
|
||||
rightConstraints = [
|
||||
toggleView.leadingAnchor.constraint(equalTo: leadingAnchor),
|
||||
label.leadingAnchor.constraint(equalTo: toggleView.trailingAnchor, constant: spacingBetween),
|
||||
label.trailingAnchor.constraint(equalTo: trailingAnchor)
|
||||
label.trailingAnchor.constraint(lessThanOrEqualTo: trailingAnchor)
|
||||
]
|
||||
|
||||
}
|
||||
@ -227,6 +231,7 @@ open class Toggle: Control, Changeable {
|
||||
private var showLabel: Bool {
|
||||
showText && !statusText.isEmpty
|
||||
}
|
||||
|
||||
private func updateLabel() {
|
||||
label.isHidden = !showLabel
|
||||
|
||||
@ -250,7 +255,6 @@ open class Toggle: Control, Changeable {
|
||||
NSLayoutConstraint.deactivate(rightConstraints)
|
||||
NSLayoutConstraint.deactivate(labelConstraints)
|
||||
}
|
||||
invalidateIntrinsicContentSize()
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
|
||||
Loading…
Reference in New Issue
Block a user