KKGridView icon indicating copy to clipboard operation
KKGridView copied to clipboard

Can't get transparent background on cells

Open sarperdag opened this issue 13 years ago • 2 comments

Here is the code I have. I am using custom cells loaded from xibs and did everything possible to create transparent backgrounds. No luck.

AlbumsViewController

- (KKGridViewCell *)gridView:(KKGridView *)gridView cellForItemAtIndexPath:(KKIndexPath *)indexPath {

    NSDictionary *album = [self.albums objectAtIndex:indexPath.section];
    NSDictionary *photo = [[album arrayForKey:@"photos"] objectAtIndex:indexPath.index];

    PhotoGridCell *cell = [[[NSBundle mainBundle] loadNibNamed:@"PhotoGridCell" owner:self options:nil] objectAtIndex: 0];
    cell.reuseIdentifier = @"PhotoCell";
    [cell updateCellInfo:photo];

    cell.contentView.backgroundColor = [UIColor clearColor];
    cell.contentView.opaque = NO;

    return cell;
}

PhotoGridCell

@implementation PhotoGridCell

- (void) updateCellInfo:(NSDictionary *) data {

    [imageView setImageWithURL:[NSURL URLWithString:[data stringForKey:@"url"]]];
    imageView.contentMode = UIViewContentModeScaleAspectFill;
    [imageView setClipsToBounds:YES];

    self.backgroundColor = [UIColor clearColor];
    self.contentView.opaque = NO;
    self.contentView.backgroundColor = [UIColor clearColor];
}

@end

sarperdag avatar Feb 13 '12 11:02 sarperdag

Hmmm... I suspect this is an issue with the cell's backgroundView. Try setting its color to [UIColor clearColor].

jonsterling avatar Apr 03 '12 23:04 jonsterling

try this:

cell.contentView.backgroundColor = [UIColor clearColor];
cell.backgroundView.backgroundColor = [UIColor clearColor];
cell.backgroundColor = [UIColor clearColor];

I guess they are stacked on each other so you have to set all of them transparent.

Nadavrbn avatar May 15 '12 07:05 Nadavrbn