Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make the background of UICollection view as transparent without making the cells in it transparent in Swift

I have a collection view and of course I also have the cells in it. If in the property inspector I change the alpha of collection view to 0, the cells in it also become transparent. Is there a way to make the background transparent of the collection view only so the image behind it is visible?

like image 833
laser2302 Avatar asked Feb 05 '16 11:02

laser2302


2 Answers

using in Swift 3:

collectionView.backgroundColor = UIColor.clear.withAlphaComponent(0)
like image 73
Kassem Itani Avatar answered Oct 21 '22 11:10

Kassem Itani


You can change the cell colour to clear and set the background to nil to see whats underneath the collectionView. Like this:

  collectionview.backgroundView = nil;
  collectionview.backgroundColor = [UIColor clearColor];
like image 42
Reshmi Majumder Avatar answered Oct 21 '22 09:10

Reshmi Majumder