Caption max height

This commit is contained in:
Justin Mazzocchi 2021-03-10 17:40:03 -08:00
parent e2d0b37f3f
commit 045524f6a5
No known key found for this signature in database
GPG key ID: E223E6937AAFB01C

View file

@ -111,6 +111,7 @@ final class ImageViewController: UIViewController {
descriptionBackgroundView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
descriptionBackgroundView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
descriptionBackgroundView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
descriptionTextView.heightAnchor.constraint(lessThanOrEqualTo: view.heightAnchor, multiplier: 1 / 4),
descriptionTextView.leadingAnchor.constraint(
equalTo: descriptionBackgroundView.layoutMarginsGuide.leadingAnchor),
descriptionTextView.topAnchor.constraint(equalTo: descriptionBackgroundView.topAnchor),
@ -172,6 +173,15 @@ final class ImageViewController: UIViewController {
?? Attachment.AttachmentType.image.accessibilityName
contentView.isAccessibilityElement = true
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
let textHeight = descriptionTextView.sizeThatFits(.init(
width: descriptionTextView.frame.width,
height: .greatestFiniteMagnitude)).height
descriptionTextView.isScrollEnabled = textHeight > descriptionTextView.frame.height
}
}
extension ImageViewController {