Skip to content

Commit

Permalink
Work magic numbers out of Adaptive Panel (Custom Layout Guide) example (
Browse files Browse the repository at this point in the history
  • Loading branch information
warpling authored Dec 5, 2020
1 parent 0a0f001 commit 199a771
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions Examples/Samples/Sources/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@
<outlet property="footerView" destination="SEa-7Y-wa9" id="Gzj-dP-YXl"/>
<outlet property="headerView" destination="t7x-eG-MKh" id="njM-un-U8q"/>
<outlet property="scrollView" destination="kRA-qy-GpJ" id="iWC-o4-APi"/>
<outlet property="stackView" destination="Gs4-S6-Goh" id="f1D-bO-mjr"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="pnR-69-Ek4" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
Expand Down
15 changes: 9 additions & 6 deletions Examples/Samples/Sources/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class SampleListViewController: UIViewController {
case .showNavigationController: return "Show Navigation Controller"
case .showTopPositionedPanel: return "Show Top Positioned Panel"
case .showAdaptivePanel: return "Show Adaptive Panel"
case .showAdaptivePanelWithCustomGuide: return "Show Adaptive Panel(Custom Layout Guide)"
case .showAdaptivePanelWithCustomGuide: return "Show Adaptive Panel (Custom Layout Guide)"
}
}

Expand Down Expand Up @@ -1348,6 +1348,7 @@ class ImageViewController: UIViewController {
@IBOutlet weak var headerView: UIView!
@IBOutlet weak var footerView: UIView!
@IBOutlet weak var scrollView: UIScrollView!
@IBOutlet weak var stackView: UIStackView!

enum Mode {
case onlyImage
Expand All @@ -1366,12 +1367,14 @@ class ImageViewController: UIViewController {
self.footerView.isHidden = false
let guide = UILayoutGuide()
view.addLayoutGuide(guide)
// 49 is the height of header and footer

NSLayoutConstraint.activate([
guide.topAnchor.constraint(equalTo: scrollView.contentLayoutGuide.topAnchor, constant: -49),
guide.leftAnchor.constraint(equalTo: scrollView.contentLayoutGuide.leftAnchor),
guide.bottomAnchor.constraint(equalTo: scrollView.contentLayoutGuide.bottomAnchor, constant: 49),
guide.rightAnchor.constraint(equalTo: scrollView.contentLayoutGuide.rightAnchor),
scrollView.heightAnchor.constraint(equalTo: scrollView.contentLayoutGuide.heightAnchor),

guide.topAnchor.constraint(equalTo: stackView.topAnchor),
guide.leftAnchor.constraint(equalTo: stackView.leftAnchor),
guide.bottomAnchor.constraint(equalTo: stackView.bottomAnchor),
guide.rightAnchor.constraint(equalTo: stackView.rightAnchor),
])
return guide
}
Expand Down

0 comments on commit 199a771

Please sign in to comment.