Fix poll button

This commit is contained in:
Justin Mazzocchi 2021-02-07 10:35:33 -08:00
parent b7f792a7d7
commit 483f519f4b
No known key found for this signature in database
GPG key ID: E223E6937AAFB01C

View file

@ -12,7 +12,6 @@ final class PollOptionButton: UIButton {
titleLabel?.numberOfLines = 0 titleLabel?.numberOfLines = 0
titleLabel?.lineBreakMode = .byWordWrapping titleLabel?.lineBreakMode = .byWordWrapping
contentHorizontalAlignment = .leading contentHorizontalAlignment = .leading
titleEdgeInsets = Self.titleEdgeInsets
let attributedTitle = NSMutableAttributedString(string: title) let attributedTitle = NSMutableAttributedString(string: title)
@ -32,6 +31,10 @@ final class PollOptionButton: UIButton {
setContentCompressionResistancePriority(.required, for: .vertical) setContentCompressionResistancePriority(.required, for: .vertical)
imageView?.translatesAutoresizingMaskIntoConstraints = false
imageView?.widthAnchor.constraint(greaterThanOrEqualToConstant: .minimumButtonDimension).isActive = true
imageView?.contentMode = .scaleAspectFit
heightAnchor.constraint(equalTo: titleLabel!.heightAnchor).isActive = true heightAnchor.constraint(equalTo: titleLabel!.heightAnchor).isActive = true
} }
@ -46,7 +49,3 @@ extension PollOptionButton {
title.height(width: width, font: .preferredFont(forTextStyle: .callout)) title.height(width: width, font: .preferredFont(forTextStyle: .callout))
} }
} }
private extension PollOptionButton {
static let titleEdgeInsets = UIEdgeInsets(top: 0, left: .defaultSpacing, bottom: 0, right: .compactSpacing)
}