Merge pull request #5 from Marcocanc/intrinsic-height
Add Intrinsic Height to PanModalHeight
This commit is contained in:
commit
f71fa70302
|
|
@ -35,4 +35,8 @@ public enum PanModalHeight: Equatable {
|
|||
*/
|
||||
case contentHeightIgnoringSafeArea(CGFloat)
|
||||
|
||||
/**
|
||||
Sets the height to be the intrinsic content height
|
||||
*/
|
||||
case intrinsicHeight
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,6 +90,12 @@ extension PanModalPresentable where Self: UIViewController {
|
|||
return bottomYPos - (height + bottomLayoutOffset)
|
||||
case .contentHeightIgnoringSafeArea(let height):
|
||||
return bottomYPos - height
|
||||
case .intrinsicHeight:
|
||||
view.layoutIfNeeded()
|
||||
let targetSize = CGSize(width: (presentedVC?.containerView?.bounds ?? UIScreen.main.bounds).width,
|
||||
height: UIView.layoutFittingCompressedSize.height)
|
||||
let intrinsicHeight = view.systemLayoutSizeFitting(targetSize).height
|
||||
return bottomYPos - (intrinsicHeight + bottomLayoutOffset)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -89,6 +89,7 @@ class StackedProfileViewController: UIViewController, PanModalPresentable {
|
|||
|
||||
roleLabel.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
|
||||
roleLabel.topAnchor.constraint(equalTo: nameLabel.bottomAnchor, constant: 4.0).isActive = true
|
||||
bottomLayoutGuide.topAnchor.constraint(greaterThanOrEqualTo: roleLabel.bottomAnchor).isActive = true
|
||||
}
|
||||
|
||||
// MARK: - Pan Modal Presentable
|
||||
|
|
@ -98,7 +99,7 @@ class StackedProfileViewController: UIViewController, PanModalPresentable {
|
|||
}
|
||||
|
||||
var longFormHeight: PanModalHeight {
|
||||
return .contentHeight(300)
|
||||
return .intrinsicHeight
|
||||
}
|
||||
|
||||
var anchorModalToLongForm: Bool {
|
||||
|
|
|
|||
Loading…
Reference in New Issue