KelvinJin / AnimatedCollectionViewLayout

A UICollectionViewLayout subclass that adds custom transitions/animations to the UICollectionView without effecting your existing code.
MIT License
4.74k stars 350 forks source link

How to make parallax cell not effect text? #48

Closed JayceBryce closed 5 years ago

JayceBryce commented 5 years ago

Right not it seems like the Parallax effects the background of the cell and what's in front. I was wondering if there is a way to change this so the text on the cell is not effected by Parallax? Therefore the "Text/UILabel" does not move with the Parallax as you scroll?

KelvinJin commented 5 years ago

I'm not 100% sure if I understand you. If you could provide some sort of illustration that would be nice.

Regardless, your assumption is correct. The parallax effect this library provides is by moving the contentView of the cell slower (hence travel longer) than the cell itself. So basically if you have two elements say a label and an icon, you can put one in the contentView and another in backgroundView and what you'll get is that the one in the contentView will move slower (the parallax effect) and the one in the backgroundView will move together with the cell.

In your case, if you want some text not moving with the parallax then putting it in the backgroundView instead of contentView.

JayceBryce commented 5 years ago

@KelvinJin Thanks for replying. I am using your sample project and here is an illustration of what I mean:

parallax

In your sample project, both the textLabel and background color is in the contentView. Because of this everything has the parallax effect.

You said above that I can add items to a backgroundView and that will not have the parallax effect. I am not sure how to do this. How would you put the textLabel outside of the contentView so it has no parallax effect? Please use your sample project as an example.

KelvinJin commented 5 years ago

Check parallax-demo branch. It's all about how much you know about UICollectionViewCell to be honest.