Skip to content

Commit 199a771

Browse files
authored
Work magic numbers out of Adaptive Panel (Custom Layout Guide) example (#412)
1 parent 0a0f001 commit 199a771

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

Examples/Samples/Sources/Base.lproj/Main.storyboard

+1
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@
352352
<outlet property="footerView" destination="SEa-7Y-wa9" id="Gzj-dP-YXl"/>
353353
<outlet property="headerView" destination="t7x-eG-MKh" id="njM-un-U8q"/>
354354
<outlet property="scrollView" destination="kRA-qy-GpJ" id="iWC-o4-APi"/>
355+
<outlet property="stackView" destination="Gs4-S6-Goh" id="f1D-bO-mjr"/>
355356
</connections>
356357
</viewController>
357358
<placeholder placeholderIdentifier="IBFirstResponder" id="pnR-69-Ek4" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>

Examples/Samples/Sources/ViewController.swift

+9-6
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class SampleListViewController: UIViewController {
4747
case .showNavigationController: return "Show Navigation Controller"
4848
case .showTopPositionedPanel: return "Show Top Positioned Panel"
4949
case .showAdaptivePanel: return "Show Adaptive Panel"
50-
case .showAdaptivePanelWithCustomGuide: return "Show Adaptive Panel(Custom Layout Guide)"
50+
case .showAdaptivePanelWithCustomGuide: return "Show Adaptive Panel (Custom Layout Guide)"
5151
}
5252
}
5353

@@ -1348,6 +1348,7 @@ class ImageViewController: UIViewController {
13481348
@IBOutlet weak var headerView: UIView!
13491349
@IBOutlet weak var footerView: UIView!
13501350
@IBOutlet weak var scrollView: UIScrollView!
1351+
@IBOutlet weak var stackView: UIStackView!
13511352

13521353
enum Mode {
13531354
case onlyImage
@@ -1366,12 +1367,14 @@ class ImageViewController: UIViewController {
13661367
self.footerView.isHidden = false
13671368
let guide = UILayoutGuide()
13681369
view.addLayoutGuide(guide)
1369-
// 49 is the height of header and footer
1370+
13701371
NSLayoutConstraint.activate([
1371-
guide.topAnchor.constraint(equalTo: scrollView.contentLayoutGuide.topAnchor, constant: -49),
1372-
guide.leftAnchor.constraint(equalTo: scrollView.contentLayoutGuide.leftAnchor),
1373-
guide.bottomAnchor.constraint(equalTo: scrollView.contentLayoutGuide.bottomAnchor, constant: 49),
1374-
guide.rightAnchor.constraint(equalTo: scrollView.contentLayoutGuide.rightAnchor),
1372+
scrollView.heightAnchor.constraint(equalTo: scrollView.contentLayoutGuide.heightAnchor),
1373+
1374+
guide.topAnchor.constraint(equalTo: stackView.topAnchor),
1375+
guide.leftAnchor.constraint(equalTo: stackView.leftAnchor),
1376+
guide.bottomAnchor.constraint(equalTo: stackView.bottomAnchor),
1377+
guide.rightAnchor.constraint(equalTo: stackView.rightAnchor),
13751378
])
13761379
return guide
13771380
}

0 commit comments

Comments
 (0)