jeudi 23 juin 2016

Image with alpha draw with black background others with white...?

I have this UICollectionView that shows thumbnails. These thumbnails are created from images on a remote server and some of these images contain transparency. When these images are downloaded and miniaturized for the cells, sometimes the same images show with a black background, sometimes with white.

This is where these colors come:

UICollectionViewCell

  • opaque = ON
  • clear graphics context = ON
  • clip subviews = ON
  • autorisize subviews = ON
  • background color = default

ImageView inside the cell

  • opaque = ON
  • clear graphics context = ON
  • clip subviews = OFF
  • autorisize subviews = ON
  • background color = default
  • tint = default

Collection View * Background color = black

Black is the collection view background color. For some reason the transparent image drawn inside the cell makes the whole cell that is opaque become transparent and show the collection view background color.

I have added both these lines, just to check, after assigning the image to the image view. No change. I have checked the assigned images and they are ok. If I change the collection view color to red, then red will show there.

[thumbnailView setNeedsDisplay];
[thumbnailView setNeedsLayout];

How do I solve that?

Aucun commentaire:

Enregistrer un commentaire