seemingly fixed the spacing issue.
This commit is contained in:
parent
6a768fb18b
commit
83cf1850ef
@ -60,6 +60,10 @@ import Foundation
|
||||
leftTextLabel?.updateView(size)
|
||||
rightTextLabel?.updateView(size)
|
||||
|
||||
if let leftText = leftTextLabel?.text, let rightText = rightTextLabel?.text, !leftText.isEmpty && !rightText.isEmpty {
|
||||
rightTextLabel?.preferredMaxLayoutWidth = size * 0.4 - PaddingDefaultHorizontalSpacing
|
||||
}
|
||||
|
||||
layoutIfNeeded()
|
||||
}
|
||||
|
||||
@ -74,6 +78,9 @@ import Foundation
|
||||
let leftTextLabel = Label.commonLabelB1(true)
|
||||
let rightTextLabel = Label.commonLabelB1(true)
|
||||
|
||||
leftTextLabel.translatesAutoresizingMaskIntoConstraints = false
|
||||
rightTextLabel.translatesAutoresizingMaskIntoConstraints = false
|
||||
|
||||
self.leftTextLabel = leftTextLabel
|
||||
self.rightTextLabel = rightTextLabel
|
||||
|
||||
@ -93,12 +100,10 @@ import Foundation
|
||||
leftTextLabel?.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true
|
||||
|
||||
if let rightLabelLeadingAnchor = rightTextLabel?.leadingAnchor {
|
||||
leftTextLabelTrailing = leftTextLabel?.trailingAnchor.constraint(equalTo: rightLabelLeadingAnchor, constant: -PaddingOne)
|
||||
leftTextLabelTrailing = leftTextLabel?.trailingAnchor.constraint(equalTo: rightLabelLeadingAnchor, constant: -PaddingDefaultHorizontalSpacing)
|
||||
leftTextLabelTrailing?.isActive = true
|
||||
}
|
||||
|
||||
NSLayoutConstraint.constraintPinSubview(leftTextLabel, pinTop: true, pinBottom: false, pinLeft: true, pinRight: false)
|
||||
|
||||
let leftTextBottom = leftTextLabel?.bottomAnchor.constraint(equalTo: bottomAnchor)
|
||||
leftTextBottom?.priority = UILayoutPriority(249)
|
||||
leftTextBottom?.isActive = true
|
||||
@ -107,7 +112,8 @@ import Foundation
|
||||
bottomAnchor.constraint(greaterThanOrEqualTo: leftLabelBottomAnchor).isActive = true
|
||||
}
|
||||
|
||||
NSLayoutConstraint.constraintPinSubview(rightTextLabel, pinTop: true, pinBottom: false, pinLeft: false, pinRight: true)
|
||||
rightTextLabel?.topAnchor.constraint(equalTo: topAnchor).isActive = true
|
||||
rightTextLabel?.trailingAnchor.constraint(equalTo: trailingAnchor).isActive = true
|
||||
|
||||
let rightTextBottom = rightTextLabel?.bottomAnchor.constraint(equalTo: bottomAnchor)
|
||||
rightTextBottom?.priority = UILayoutPriority(rawValue: 249)
|
||||
@ -117,38 +123,55 @@ import Foundation
|
||||
bottomAnchor.constraint(greaterThanOrEqualTo: rightLabelBottomAnchor).isActive = true
|
||||
}
|
||||
|
||||
leftTextWidth = leftTextLabel?.widthAnchor.constraint(equalTo: widthAnchor, multiplier: 0.6)
|
||||
leftTextWidth?.priority = UILayoutPriority(rawValue: 100)
|
||||
leftTextWidth = leftTextLabel?.widthAnchor.constraint(greaterThanOrEqualTo: widthAnchor, multiplier: 0.6)
|
||||
leftTextWidth?.priority = UILayoutPriority(rawValue: 995)
|
||||
leftTextWidth?.isActive = true
|
||||
|
||||
rightTextWidth = rightTextLabel?.widthAnchor.constraint(equalTo: widthAnchor, multiplier: 0.4)
|
||||
rightTextWidth?.priority = UILayoutPriority(rawValue: 101)
|
||||
let leftTextHeight = leftTextLabel?.heightAnchor.constraint(greaterThanOrEqualToConstant: 0)
|
||||
leftTextHeight?.priority = UILayoutPriority(rawValue: 901)
|
||||
leftTextHeight?.isActive = true
|
||||
|
||||
rightTextWidth = rightTextLabel?.widthAnchor.constraint(lessThanOrEqualTo: widthAnchor, multiplier: 0.4)
|
||||
rightTextWidth?.priority = UILayoutPriority(rawValue: 906)
|
||||
rightTextWidth?.isActive = true
|
||||
|
||||
let rightTextHeight = rightTextLabel?.heightAnchor.constraint(greaterThanOrEqualToConstant: 0)
|
||||
rightTextHeight?.priority = UILayoutPriority(rawValue: 901)
|
||||
rightTextHeight?.isActive = true
|
||||
|
||||
if let leftLabelBaslineAnchor = leftTextLabel?.firstBaselineAnchor {
|
||||
rightTextLabel?.firstBaselineAnchor.constraint(equalTo: leftLabelBaslineAnchor).isActive = true
|
||||
}
|
||||
|
||||
leftTextLabel?.setContentHuggingPriority(UILayoutPriority(rawValue: 801), for: .horizontal)
|
||||
rightTextLabel?.setContentHuggingPriority(UILayoutPriority(rawValue: 802), 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)
|
||||
|
||||
leftTextLabel?.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||
rightTextLabel?.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||
rightTextLabel?.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 902), for: .horizontal)
|
||||
}
|
||||
|
||||
private func constrainLeftLabel() {
|
||||
|
||||
leftTextLabelTrailing?.constant = 0
|
||||
leftTextWidth?.isActive = false
|
||||
leftTextWidth = leftTextLabel?.widthAnchor.constraint(equalTo: widthAnchor, multiplier: 1.0)
|
||||
leftTextWidth?.priority = UILayoutPriority(rawValue: 999)
|
||||
leftTextWidth?.isActive = true
|
||||
|
||||
leftTextLabel?.setContentHuggingPriority(.required, for: .vertical)
|
||||
}
|
||||
|
||||
private func constrainRightLabel() {
|
||||
|
||||
leftTextLabelTrailing?.constant = 0
|
||||
rightTextWidth?.isActive = false
|
||||
rightTextWidth = rightTextLabel?.widthAnchor.constraint(equalTo: widthAnchor, multiplier: 1.0)
|
||||
rightTextWidth?.priority = UILayoutPriority(rawValue: 999)
|
||||
rightTextWidth?.isActive = true
|
||||
|
||||
rightTextLabel?.setContentHuggingPriority(.required, for: .vertical)
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
|
||||
Loading…
Reference in New Issue
Block a user