jeudi 25 juin 2015

UITableViewCell shadow disappears after scroll

I have subclassed UITableViewCell class to add shadow below my cell. The shadow is added correctly, when TableView appears on screen. But, when I scroll tableview down, and cell with shadow hides above the screen, the shadow disappears.

- (void)layoutSubviews {
    [super layoutSubviews];
    if (self.shouldAddShadow) {
        self.layer.shadowOpacity = 0.5;
        self.layer.shadowRadius = 1.5;
        self.layer.shadowOffset = CGSizeMake(0, 3);
        self.layer.shadowColor = [[[UIColor appDarkDividerColor] colorWithAlphaComponent:0.9] CGColor];
        [self setClipsToBounds:NO];
        [self.layer setMasksToBounds:NO];
        CGRect shadowFrame = self.layer.bounds;
        CGPathRef shadowPath = [UIBezierPath bezierPathWithRect:shadowFrame].CGPath;
        self.layer.shadowPath = shadowPath;
    }
}

See more ..

Aucun commentaire:

Enregistrer un commentaire