From f23cee6ba90fb243fa5ab391d6abbd64a21b873e Mon Sep 17 00:00:00 2001 From: "Christiano, Kevin" Date: Wed, 19 Jun 2019 16:17:22 -0400 Subject: [PATCH] further attention paid to the preferredMaxLayout. --- MVMCoreUI/Atoms/Views/LeftRightLabelView.swift | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/LeftRightLabelView.swift b/MVMCoreUI/Atoms/Views/LeftRightLabelView.swift index 2b71c04e..81d9f2ff 100644 --- a/MVMCoreUI/Atoms/Views/LeftRightLabelView.swift +++ b/MVMCoreUI/Atoms/Views/LeftRightLabelView.swift @@ -71,9 +71,11 @@ import Foundation // Resolves text layout issues found between both dynamically sized labels, number is not exact but performs as required. if leftTextLabel.hasText && rightTextLabel.hasText { - rightTextLabel.preferredMaxLayoutWidth = floor((size - 16) * 0.4) - } else if rightTextLabel.hasText { - rightTextLabel.preferredMaxLayoutWidth = 0.0 + let padding = MFStyler.defaultHorizontalPadding(forSize: size) * 2 + let maximumTextWidth = (size - (padding + 16 + layoutMargins.left + layoutMargins.right)) * 0.4 + rightTextLabel.preferredMaxLayoutWidth = round(maximumTextWidth) + } else { + rightTextLabel.preferredMaxLayoutWidth = 0 } } @@ -144,6 +146,9 @@ import Foundation deactivateMiddleConstraint() constrainBothLabels() + leftTextLabel.text = "" + rightTextLabel.text = "" + backgroundColor = nil } private func deactivateMiddleConstraint() {