Skip to content

pgpt10/CollectionViewGradientSample

Repository files navigation

Selectively Add & Remove Gradient — UICollectionViewCell

Playing with Collection Views is so much fun and challenging. One of the things I came across is using gradients with collection views.

Adding gradient to a UICollectionView or UICollectionViewCell is as simple as adding it to any other view. We had a detailed discussion over it in the previous article.

Another challenge is, what if we need to add gradient to a UICollectionViewCell on selection and remove it when the UICollectionViewCell is de-selected.

Preview

Pre-requisites

Before we start coding, let’s see what we already have 🧐 and how can we use that to solve our problem statement.

Adding gradient to a view — In this article we had a detailed discussion on how to get that working.

Changing the UICollectionViewCell’s properties based on its selection stateHere we have already discussed how isSelected handles that.

Combining the above 2, now we’re left with “adding the gradient to cell when it is selected and removing it when it is de-selected”. We’re already halfway there, just need to put our knowledge in the right place. 🎯

What's in the Project

The project includes all the implementation details of how you can handle UICollectionViewCell selection with gradient.

Promotions

For more iOS related stuff, you can follow me here.

About

Selectively Add & Remove Gradient — UICollectionViewCell

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages