@@ -11,46 +11,57 @@ import SwiftUI
1111
1212class PlanetViewController : UIViewController {
1313
14- lazy var heroLabel = UILabel ( ) . withHeroStyle
15- lazy var subtitleLabel = UILabel ( ) . withSubtitleStyle
16- lazy var image = UIImageView ( )
17- lazy var introLabel = UILabel ( ) . withIntroStyle
18- lazy var titleLabel = UILabel ( ) . withTitleStyle
19- lazy var paragraphLabel = UILabel ( ) . withParagraphStyle
14+ lazy var heroLabel = UILabel ( ) . withHeroStyle. inspect
15+ lazy var subtitleLabel = UILabel ( ) . withSubtitleStyle. inspect
16+ lazy var image = UIImageView ( ) . inspect
17+ lazy var introLabel = UILabel ( ) . withIntroStyle. inspect
18+ lazy var titleLabel = UILabel ( ) . withTitleStyle. inspect
19+ lazy var paragraphLabel = UILabel ( ) . withParagraphStyle. inspect
2020
21- lazy var body = UIStackView ( )
22- . vertical ( spacing: 5 )
21+ lazy var stackView = UIStackView ( )
22+ . vertical ( spacing: UI . StackView . spacing )
2323 . views (
24- heroLabel
25- . inspect,
26- subtitleLabel
27- . inspect,
28- image
29- . inspect,
30- introLabel
31- . inspect,
32- titleLabel
33- . inspect,
24+ heroLabel,
25+ subtitleLabel,
26+ image,
27+ introLabel,
28+ titleLabel,
3429 paragraphLabel
35- . inspect,
36- UIView
37- . spacer
38- . inspect
3930 )
4031 . with {
41- $0. setCustomSpacing ( 25 , after: introLabel)
42- $0. setCustomSpacing ( 25 , after: titleLabel)
32+ $0. setCustomSpacing ( 20 + 2 * UI. StackView. spacing, after: introLabel)
33+ $0. setCustomSpacing ( 20 + 2 * UI. StackView. spacing, after: titleLabel)
34+ }
35+
36+ lazy var scrollView = UIScrollView ( )
37+ . with {
38+ $0. clipsToBounds = false
4339 }
4440
4541 override func viewDidLoad( ) {
4642 super. viewDidLoad ( )
47- view. addSubview ( body)
43+
44+ // Colors.
4845 view. backgroundColor = . background
4946 overrideUserInterfaceStyle = . dark
50- body. pin (
47+
48+ // Hierarchy.
49+ view. addSubview ( scrollView)
50+ scrollView. addSubview ( stackView)
51+ scrollView. pin (
5152 to: view. safeAreaLayoutGuide,
52- insets: UIEdgeInsets ( top: 25 , left: 25 , bottom: 25 , right: 25 )
53+ insets: . zero
54+ )
55+ stackView. pin (
56+ to: scrollView,
57+ insets: UI . padding
5358 )
59+
60+ // Vertical scrolling.
61+ stackView. widthAnchor. constraint (
62+ equalTo: scrollView. widthAnchor,
63+ constant: - UI . padding . left - UI. padding. right
64+ ) . isActive = true
5465 }
5566
5667 override func viewWillAppear( _ animated: Bool ) {
0 commit comments