# UICollectionView Custom Layout Tutorial: Pinterest

**URL:** <https://forums.kodeco.com/t/uicollectionview-custom-layout-tutorial-pinterest/733>\
**Category:** 🎓 Courses & Articles\
**Created:** [February 28, 2016, 8:02pm UTC](https://forums.kodeco.com/t/uicollectionview-custom-layout-tutorial-pinterest/733 "2016-02-28T20:02:39Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![daniavram](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/daniavram/32/81060_2.png) [@daniavram](https://forums.kodeco.com/u/daniavram)\
**Post date:** [September 1, 2016, 2:28pm UTC](https://forums.kodeco.com/t/uicollectionview-custom-layout-tutorial-pinterest/733/21 "2016-09-01T14:28:23Z")

</div>

am also trying to find a solution. no luck. did you manage to do it? if so, how? 🙂

---

<div class="post-metadata">

**Author:** ![wj313](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/wj313/32/42348_2.png) [@wj313](https://forums.kodeco.com/u/wj313)\
**Post date:** [September 23, 2016, 5:18pm UTC](https://forums.kodeco.com/t/uicollectionview-custom-layout-tutorial-pinterest/733/22 "2016-09-23T17:18:05Z")

</div>

Do anyone know how to add a supplementary view for a header of the custom collectionView layout?

---

<div class="post-metadata">

**Author:** ![vietstone](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/vietstone/32/74092_2.png) [@vietstone](https://forums.kodeco.com/u/vietstone)\
**Post date:** [September 25, 2016, 2:41pm UTC](https://forums.kodeco.com/t/uicollectionview-custom-layout-tutorial-pinterest/733/23 "2016-09-25T14:41:58Z")

</div>

Nice tutorial! Very helpful

---

<div class="post-metadata">

**Author:** ![kennouf](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/kennouf/32/77486_2.png) [@kennouf](https://forums.kodeco.com/u/kennouf)\
**Post date:** [October 3, 2016, 2:35pm UTC](https://forums.kodeco.com/t/uicollectionview-custom-layout-tutorial-pinterest/733/24 "2016-10-03T14:35:52Z")

</div>

Hey guys, thanks for the great tutorial 🙂 I notice it has been updated for swift !

That’s awesome, but is an objC version still available ? In order to smoothly integrate it in an older project that doesn’t have any Swift in it

Thanks in advance !

---

<div class="post-metadata">

**Author:** ![rmonson](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/rmonson/32/72205_2.png) [@rmonson](https://forums.kodeco.com/u/rmonson)\
**Post date:** [October 14, 2016, 1:26pm UTC](https://forums.kodeco.com/t/uicollectionview-custom-layout-tutorial-pinterest/733/25 "2016-10-14T13:26:01Z")

</div>

Just wanted to say that this article save my day or probably three or four days. Anyway, thank you very much!

---

<div class="post-metadata">

**Author:** ![trickyrick](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/trickyrick/32/44809_2.png) [@trickyrick](https://forums.kodeco.com/u/trickyrick)\
**Post date:** [October 19, 2016, 8:31pm UTC](https://forums.kodeco.com/t/uicollectionview-custom-layout-tutorial-pinterest/733/26 "2016-10-19T20:31:33Z")

</div>

I was using this layout, and had it working at one point, but now it crashes inside the line in the file AnnotatedPhotoCell.swift:

imageViewHeightLayoutConstraint.constant = attributes.photoHeight

It says that imageViewHeightLayoutConstraint is nil, even though the constraint appears in my storyboard and as an outlet in the AnnotatedPhotoCell class. Any idea what might be causing this?

---

<div class="post-metadata">

**Author:** ![omrih1010](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/omrih1010/32/50124_2.png) [@omrih1010](https://forums.kodeco.com/u/omrih1010)\
**Post date:** [December 1, 2016, 5:12pm UTC](https://forums.kodeco.com/t/uicollectionview-custom-layout-tutorial-pinterest/733/30 "2016-12-01T17:12:53Z")

</div>

Has anyone managed to use that example with images from URL?  
And if so how?  
Thanks!

---

<div class="post-metadata">

**Author:** ![hungrycoder](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/hungrycoder/32/48084_2.png) [@hungrycoder](https://forums.kodeco.com/u/hungrycoder)\
**Post date:** [December 5, 2016, 10:37am UTC](https://forums.kodeco.com/t/uicollectionview-custom-layout-tutorial-pinterest/733/32 "2016-12-05T10:37:33Z")

</div>

did you transfer this to UICollectionView? will you please send your file here im having trouble with mine. Thank you in advance jose

---

<div class="post-metadata">

**Author:** ![giannpelle](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@giannpelle](https://forums.kodeco.com/u/giannpelle)\
**Post date:** [December 12, 2016, 6:03pm UTC](https://forums.kodeco.com/t/uicollectionview-custom-layout-tutorial-pinterest/733/33 "2016-12-12T18:03:12Z")

</div>

Had the same problem; Given that you can customise the appearance of each cell giving them the size and position, I made the first cell as the header, bigger and in the center of the collection and then I moved all the other following cell down.  
Hope I helped

---

<div class="post-metadata">

**Author:** ![azcoder](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/azcoder/32/69717_2.png) [@azcoder](https://forums.kodeco.com/u/azcoder)\
**Post date:** [December 26, 2016, 1:45am UTC](https://forums.kodeco.com/t/uicollectionview-custom-layout-tutorial-pinterest/733/34 "2016-12-26T01:45:05Z")

</div>

I converted this to Swift 3 beginning with the starter code and through every steop and it works as described. Great tutorial. Thanks!

---

<div class="post-metadata">

**Author:** ![alekseynov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/alekseynov/32/52714_2.png) [@alekseynov](https://forums.kodeco.com/u/alekseynov)\
**Post date:** [December 27, 2016, 8:49am UTC](https://forums.kodeco.com/t/uicollectionview-custom-layout-tutorial-pinterest/733/35 "2016-12-27T08:49:34Z")

</div>

Kindly share this project on swift 3 or send to [alex@vectech.ru](mailto:alex@vectech.ru)  
I’ll be very grateful

---

<div class="post-metadata">

**Author:** ![azcoder](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/azcoder/32/69717_2.png) [@azcoder](https://forums.kodeco.com/u/azcoder)\
**Post date:** [December 27, 2016, 8:34pm UTC](https://forums.kodeco.com/t/uicollectionview-custom-layout-tutorial-pinterest/733/36 "2016-12-27T20:34:48Z")

</div>

I created a GIT repository for this. Let me know if you have any problems (this is my first one).

[https://github.com/AZCoder2/Pinterest.git](https://github.com/AZCoder2/Pinterest.git)

---

<div class="post-metadata">

**Author:** ![alekseynov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/alekseynov/32/52714_2.png) [@alekseynov](https://forums.kodeco.com/u/alekseynov)\
**Post date:** [December 28, 2016, 8:06am UTC](https://forums.kodeco.com/t/uicollectionview-custom-layout-tutorial-pinterest/733/37 "2016-12-28T08:06:52Z")

</div>

All works, Many Thanks!

---

<div class="post-metadata">

**Author:** ![azcoder](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/azcoder/32/69717_2.png) [@azcoder](https://forums.kodeco.com/u/azcoder)\
**Post date:** [December 28, 2016, 4:32pm UTC](https://forums.kodeco.com/t/uicollectionview-custom-layout-tutorial-pinterest/733/38 "2016-12-28T16:32:05Z")

</div>

Glad to help! Have a happy New Year. 😀 🍻

---

<div class="post-metadata">

**Author:** ![dviet](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/dviet/32/54411_2.png) [@dviet](https://forums.kodeco.com/u/dviet)\
**Post date:** [January 14, 2017, 2:28pm UTC](https://forums.kodeco.com/t/uicollectionview-custom-layout-tutorial-pinterest/733/40 "2017-01-14T14:28:53Z")

</div>

I’m trying to write this app programmatically without using storyboard. Can you have a look and help fix my codes?

---

<div class="post-metadata">

**Author:** ![azcoder](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/azcoder/32/69717_2.png) [@azcoder](https://forums.kodeco.com/u/azcoder)\
**Post date:** [January 14, 2017, 4:31pm UTC](https://forums.kodeco.com/t/uicollectionview-custom-layout-tutorial-pinterest/733/41 "2017-01-14T16:31:25Z")

</div>

Sorry, I’m no expert! I’m learning just like you. Good luck!

---

<div class="post-metadata">

**Author:** ![sravan](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/sravan/32/56707_2.png) [@sravan](https://forums.kodeco.com/u/sravan)\
**Post date:** [February 7, 2017, 4:32am UTC](https://forums.kodeco.com/t/uicollectionview-custom-layout-tutorial-pinterest/733/42 "2017-02-07T04:32:31Z")

</div>

Hi, i want to reload my collection view data after calling more products api and my cell size should change according to the image size can any one help for me

---

<div class="post-metadata">

**Author:** ![michaelsun](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@michaelsun](https://forums.kodeco.com/u/michaelsun)\
**Post date:** [April 6, 2017, 3:48am UTC](https://forums.kodeco.com/t/uicollectionview-custom-layout-tutorial-pinterest/733/43 "2017-04-06T03:48:21Z")

</div>

I kind of solve this by adding an attribute for header before I add the attributes for other items, then make the yOffsets of the following items start with the below of header:

```
    UICollectionViewLayoutAttributes *headerAtt = [UICollectionViewLayoutAttributes layoutAttributesForSupplementaryViewOfKind:UICollectionElementKindSectionHeader withIndexPath:[NSIndexPath indexPathWithIndex:0]];
    headerAtt.frame = CGRectMake(0, 0, _width, 200);
    [_cache addObject:headerAtt];

```

---

<div class="post-metadata">

**Author:** ![copernicus](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/copernicus/32/67741_2.png) [@copernicus](https://forums.kodeco.com/u/copernicus)\
**Post date:** [May 21, 2017, 2:38pm UTC](https://forums.kodeco.com/t/uicollectionview-custom-layout-tutorial-pinterest/733/44 "2017-05-21T14:38:45Z")

</div>

I’ve used this in the past with success - but lately, I’ve been developing without using storyboards and I cannot get this to work at all.The layout is just a complete mess - cells have incorrect dimensions and are placed at the wrong location. Has anybody used this without storyboards and had any success with it?

Thanks

---

<div class="post-metadata">

**Author:** ![lynx56](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/lynx56/32/102075_2.png) [@lynx56](https://forums.kodeco.com/u/lynx56)\
**Post date:** [June 8, 2017, 6:40am UTC](https://forums.kodeco.com/t/uicollectionview-custom-layout-tutorial-pinterest/733/45 "2017-06-08T06:40:57Z")

</div>

Hello and thank you for your job! Any chance for writing tutorial where UICollectionViewFlowLayoutAutomaticSize use for this?

[Previous page](https://forums.kodeco.com/t/uicollectionview-custom-layout-tutorial-pinterest/733.md?page=1)

[Next page](https://forums.kodeco.com/t/uicollectionview-custom-layout-tutorial-pinterest/733.md?page=3)
