I'm a newbie of IOS app develop. Now a day , I want to make a screen likes below picture.
How to make it?
I'm thinking about using UICollectionView but I don't know how to customize it?
-
1This question is very broad. Perhaps look for a `UICollectionView` or `UIScrollView` tutorial online and work through that first then come back with specific, focused questions. – par Dec 30 '16 at 05:27
-
@par I can make a simple UICollectionView and UIScrollView. But I don't know how to custom cell as I expected. Please help me – Bulma Dec 30 '16 at 05:30
-
@Tamachan check here for custom collectionviewcell ..http://stackoverflow.com/a/40635137/4003548. – vaibhav Dec 30 '16 at 06:26
5 Answers
You have implemented method named: "sizeForItemAt", it is used to set the size of every cell of your collection view. And your condition is satisfied because of bidirectional scrolling property of collection view. If you change the size of cell, than this may be worst for your UI.

- 69,473
- 35
- 181
- 253

- 104
- 1
- 8
Follow the steps:-
- Select collection view from storyboard (if using).
- Than go to Attributes Inspector.
- And set the Scroll Direction Vertical to Horizontal. (Vertical is default)

- 71,513
- 12
- 161
- 183

- 104
- 1
- 8
-
Thank you for the answer. I want to custom cell that displays as one column. Heigh of cell equals to heigh of view. – Bulma Dec 30 '16 at 05:36
I can do that now by below workaround
class ViewController: UIViewController, UICollectionViewDelegateFlowLayout{
...
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: 40.0, height: 500.0)
}
}
You can do it after seeing tutorial of content offset and content size of collection view. This two parameter help you to check for overlapped cell. Check content offset of every cell with the x origin of green view.

- 6,052
- 10
- 43
- 117

- 104
- 1
- 8
create cocoa touch file.
step 1
step 2
Now you will have two files created.
use xib to design your UI and CollectionViewCell class to connect xib's outlets.
Now in the main view controller where you are confirming UIcollectionViewDelegate and UIcollectionViewDataSource register the xib for an identifier.
collectionView.register(UINib(nibName: "CollectionViewCell", bundle: Bundle.main), forCellWithReuseIdentifier: "yourIdentifier")
you can use this yourIdentifer to deque item for collection view in ItemForRowAtIndexPath.
Now to Change the Scroll Direction Property. Below is the image you can refer
Or programatically you can change it by following piece of code.
if let layout = self.yourCollectionView.collectionViewLayout as? UICollectionViewFlowLayout {
layout.scrollDirection = .horizontal
}

- 985
- 1
- 8
- 18