@@ -55,8 +55,12 @@ struct LayoutDesignerCodePreviewViewModel {
55
55
}
56
56
57
57
func setup() {
58
- // use AutoLayout in real world
59
- card = UIView(frame: CGRect(x: 80, y: 100, width: frame.width - 160, height: frame.height - 200))
58
+ // preferably use AutoLayout! this is only for simplicity
59
+ let cardFrame = CGRect(x: 80,
60
+ y: 100,
61
+ width: frame.width - 160,
62
+ height: frame.height - 200)
63
+ card = UIView(frame: cardFrame)
60
64
card.backgroundColor = .gray
61
65
contentView.addSubview(card)
62
66
}
@@ -73,7 +77,10 @@ struct LayoutDesignerCodePreviewViewModel {
73
77
}
74
78
75
79
private func setupCollectionView() {
76
- collectionView = UICollectionView(frame: view.frame, collectionViewLayout: CollectionViewPagingLayout())
80
+ collectionView = UICollectionView(
81
+ frame: view.frame,
82
+ collectionViewLayout: CollectionViewPagingLayout()
83
+ )
77
84
collectionView.isPagingEnabled = true
78
85
collectionView.register(MyCell.self, forCellWithReuseIdentifier: " cell " )
79
86
collectionView.dataSource = self
@@ -87,12 +94,20 @@ struct LayoutDesignerCodePreviewViewModel {
87
94
})
88
95
}
89
96
90
- func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
97
+ func collectionView(
98
+ _ collectionView: UICollectionView,
99
+ numberOfItemsInSection section: Int
100
+ ) -> Int {
91
101
10
92
102
}
93
103
94
- func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
95
- collectionView.dequeueReusableCell(withReuseIdentifier: " cell " , for: indexPath)
104
+ func collectionView(
105
+ _ collectionView: UICollectionView,
106
+ cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
107
+ collectionView.dequeueReusableCell(
108
+ withReuseIdentifier: " cell " ,
109
+ for: indexPath
110
+ )
96
111
}
97
112
98
113
}
0 commit comments