0

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? Look  like calendar image

FelixSFD
  • 6,052
  • 10
  • 43
  • 117
Bulma
  • 990
  • 3
  • 16
  • 35
  • 1
    This 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 Answers5

1

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.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Akhilesh Sharma
  • 104
  • 1
  • 8
0

Follow the steps:-

  1. Select collection view from storyboard (if using).
  2. Than go to Attributes Inspector.
  3. And set the Scroll Direction Vertical to Horizontal. (Vertical is default)
Nirav D
  • 71,513
  • 12
  • 161
  • 183
Akhilesh Sharma
  • 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
0

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)

    }
}
FelixSFD
  • 6,052
  • 10
  • 43
  • 117
Bulma
  • 990
  • 3
  • 16
  • 35
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.

FelixSFD
  • 6,052
  • 10
  • 43
  • 117
Akhilesh Sharma
  • 104
  • 1
  • 8
-1

create cocoa touch file. step 1 enter image description here step 2 enter image description here Now you will have two files created. enter image description here 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

enter image description here

Or programatically you can change it by following piece of code.

if let layout = self.yourCollectionView.collectionViewLayout as? UICollectionViewFlowLayout {
   layout.scrollDirection = .horizontal
}
Aman Gupta
  • 985
  • 1
  • 8
  • 18