make sure mediaview isn't too tall in detail view

// FREEBIE
pull/1/head
sdkjfhsdkjhfsdlkjhfsdf 7 years ago
parent 411de65b40
commit 2c20cb9e7b

@ -300,7 +300,7 @@ class MessageDetailViewController: OWSViewController, UIScrollViewDelegate {
} }
if let mediaMessageView = mediaMessageView { if let mediaMessageView = mediaMessageView {
mediaMessageView.autoPinToSquareAspectRatio() mediaMessageView.autoMatch(.height, to: .width, of: mediaMessageView, withOffset:0, relation: .lessThanOrEqual)
} }
} }

@ -172,8 +172,16 @@ public class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate {
let stackView = wrapViewsInVerticalStack(subviews: subviews) let stackView = wrapViewsInVerticalStack(subviews: subviews)
self.addSubview(stackView) self.addSubview(stackView)
fileNameLabel?.autoPinWidthToSuperview(withMargin: 32) fileNameLabel?.autoPinWidthToSuperview(withMargin: 32)
// We want to center the stackView in it's superview while ensuring
// it's superview is big enough to contain it.
stackView.autoPinWidthToSuperview() stackView.autoPinWidthToSuperview()
stackView.autoVCenterInSuperview() stackView.autoVCenterInSuperview()
NSLayoutConstraint.autoSetPriority(UILayoutPriorityDefaultLow) {
stackView.autoPinHeightToSuperview()
}
stackView.autoPinEdge(toSuperviewEdge: .top, withInset: 0, relation: .greaterThanOrEqual)
stackView.autoPinEdge(toSuperviewEdge: .bottom, withInset: 0, relation: .greaterThanOrEqual)
} }
private func createAnimatedPreview() { private func createAnimatedPreview() {
@ -286,8 +294,16 @@ public class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate {
let stackView = wrapViewsInVerticalStack(subviews: subviews) let stackView = wrapViewsInVerticalStack(subviews: subviews)
self.addSubview(stackView) self.addSubview(stackView)
fileNameLabel?.autoPinWidthToSuperview(withMargin: 32) fileNameLabel?.autoPinWidthToSuperview(withMargin: 32)
// We want to center the stackView in it's superview while ensuring
// it's superview is big enough to contain it.
stackView.autoPinWidthToSuperview() stackView.autoPinWidthToSuperview()
stackView.autoVCenterInSuperview() stackView.autoVCenterInSuperview()
NSLayoutConstraint.autoSetPriority(UILayoutPriorityDefaultLow) {
stackView.autoPinHeightToSuperview()
}
stackView.autoPinEdge(toSuperviewEdge: .top, withInset: 0, relation: .greaterThanOrEqual)
stackView.autoPinEdge(toSuperviewEdge: .bottom, withInset: 0, relation: .greaterThanOrEqual)
} }
private func createHeroViewSize() -> CGFloat { private func createHeroViewSize() -> CGFloat {

Loading…
Cancel
Save