Group Group Group Group Group Group Group Group Group

raywenderlich.com Forums

Video Tutorial: Custom Collection View Layouts Part 2: Pinterest – Layout Attributes

Learn how to leverage custom layout attributes to simplify the implementation of a Pinterest-like custom collection view layout.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/3987-custom-collection-view-layout/lessons/3

Hi,

Small request. The background music on this tutorials is distracticting me. I am not able to concentrate on what is being told by the instructor. It is dominating the instructors voice. Can we have all the tutorials without the background music.

Hello Michael. Could you please explain a bit this piece of code?

let collectionCenter = collectionView!.frame.size.height / 2
let offset = collectionView!.contentOffset.y
let normalizedCenter = attributes.center.y - offset
		
let maxDistance = self.itemSize.height + self.minimumLineSpacing
let distance = min(abs(collectionCenter - normalizedCenter), maxDistance)
		
let ratio = (maxDistance - distance) / maxDistance

Thanks!

1 Like

I think this is the problem with all the videos in here, they are too short. I mean it feels like someone is just reading the slides. There is a lot of code in this video and relatively zero explanation. I am sorry if i am being too harsh.

I have a question, I can’t find any related subtitutes in videos, which always perplex me . Because my english listening comprehension not so good , and I hope this problem can be solved as soon as possible. Thanks.

Can’t agree more. They totally flown through the calculations with no explanations here. At least a diagram should have drawn to show which calculated intermediate value represents what on the diagram. And then also state why that particular intermediary value needs to be calculated.

Nope, none… So much for that $19…

2 Likes

I also agree. The older videos explained things clearly and in detail. I miss micpringle’s version of these videos. These video’s seem stale, brief, and without feeling. Seriously debating if I will continue my video subscription.

@jwrigh26 @howardhwlee We’ve listened to your feedback, and whilst we’ll endeavour to make sure things are better explained going forward, we have just rolled out a new feature on the site that makes all the original content available for viewing. If you head on over to https://videos.raywenderlich.com/courses/65-custom-collection-view-layout/lessons/1 you see a link that’ll take you through to the previous version of the course.

@micpringle thank you so much for responding. DIdn’t even notice the link until now. Awesome!

exactly what i was thinking ! seriously there is no explanation at all. it reminds me of an ios course i took at lynda’s it was the same. Do this and do that without any explanations

Hi, although the videos are pretty nice so far. It’s a bit hard to follow (too fast) in my opinion. I agree with tkallioras and some others. Can you please explain the code a bit more? Maybe adding some visuals to explain the maths will help? Thanks!

Still no explanation?
I also have a question on the challenge. How did this line:

layout.minimumLineSpacing = -(layout.itemSize.width * 0.5)

made the cells overlap? More specifically why only cells closer to center overlap and the ones towards the edges are still separated by a space?

Hope to hear from you :wink:

When I start the app, it looks like this (iOS 12):

Only when I start to scroll, I see the carousel layout.

How can I trigger the carouselLayout at the time of app start without having to scroll?

Answering my own question:
I did it by adding this to the MasterViewController:

override func viewDidAppear(_ animated: Bool) {
    collectionViewLayout.invalidateLayout()
}

Any better solution?

If you are here in 2019, the line “layout.estimatedItemSize” in MasterViewController breaks the carousel when it first loads. You need to use “layout.itemSize” instead.

Where also I have not found a suitable explanation about why a copy of
super.layoutAttributesForElements(in: rect) is required to be returned, as mentioned in the video, to prevent memory issues, how does directly modifying the attributes from the super call create memory issues?

@skyrocketsw Can you please help with this when you get a chance? Thank you - much appreciated! :]

I am sorry to say this but I have to say. The quality of the tutorial is poor as it does not consider different screen sizes into consideration and also it feels like the instructor wants to just finish off the whole course in 5 minutes.

@lancy98 Please let us know what you don’t understand exactly when you get a chance. Thank you!