有一个带自定义单元的UICollectionView
。其中有UIImageView 需要添加阴影。但是,在cell 出现在collection view又回去之后 ,才能开始画阴影。
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier = @"genreCell";
GenreViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
cell.genreImageView.layer.shadowRadius = 1.5;
cell.genreImageView.layer.shadowOffset = CGSizeMake(-1, -1);
cell.genreImageView.layer.shadowOpacity = 0.5;
cell.genreImageView.layer.shadowColor = [UIColor blackColor].CGColor;
cell.genreImageView.layer.shadowPath = [UIBezierPath bezierPathWithRect:cell.genreImageView.bounds].CGPath;
return cell;
}