From b51c1c03cb3cca49092430c37687a4cda12a27cd Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sat, 22 May 2021 11:44:50 -0400 Subject: [PATCH] Fix poll option percentages getting cut off Closes #120 --- Tusker/Views/Poll/PollOptionView.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Tusker/Views/Poll/PollOptionView.swift b/Tusker/Views/Poll/PollOptionView.swift index bf5e5467..d902244a 100644 --- a/Tusker/Views/Poll/PollOptionView.swift +++ b/Tusker/Views/Poll/PollOptionView.swift @@ -30,6 +30,7 @@ class PollOptionView: UIView { let label = EmojiLabel() label.translatesAutoresizingMaskIntoConstraints = false label.numberOfLines = 0 + label.font = .preferredFont(forTextStyle: .callout) label.text = option.title label.setEmojis(poll.emojis, identifier: poll.id) addSubview(label) @@ -37,7 +38,10 @@ class PollOptionView: UIView { let percentLabel = UILabel() percentLabel.translatesAutoresizingMaskIntoConstraints = false percentLabel.text = "100%" + percentLabel.font = label.font percentLabel.isHidden = true + percentLabel.setContentCompressionResistancePriority(.required, for: .horizontal) + percentLabel.setContentHuggingPriority(.required, for: .horizontal) addSubview(percentLabel) if (poll.voted ?? false) || poll.effectiveExpired, @@ -76,7 +80,7 @@ class PollOptionView: UIView { label.topAnchor.constraint(equalTo: topAnchor), label.bottomAnchor.constraint(equalTo: bottomAnchor), label.leadingAnchor.constraint(equalTo: checkbox.trailingAnchor, constant: 8), - label.trailingAnchor.constraint(equalTo: percentLabel.leadingAnchor), + label.trailingAnchor.constraint(equalTo: percentLabel.leadingAnchor, constant: -4), percentLabel.topAnchor.constraint(equalTo: topAnchor), percentLabel.bottomAnchor.constraint(equalTo: bottomAnchor),