- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
NSString *cellIdentifier = @"cellCollection";
[self.MainCollectionView registerClass:[CVC_ImageWithLabel class] forCellWithReuseIdentifier:cellIdentifier];
CVC_ImageWithLabel *customCell = (CVC_ImageWithLabel *)[self.MainCollectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
//cell text
customCell.NameLabel.text = [data_Array objectAtIndex:indexPath.row];
//cell image
customCell.CellImage.image=[UIImage imageNamed:[image_Array objectAtIndex:indexPath.row]];
customCell.CellImage.contentMode = UIViewContentModeScaleAspectFit;
return customCell;
}
先生,你能帮助我吗?
我试图添加下面的代码,但没有这样做。
customCell.layer.shouldRasterize = YES;
customCell.layer.rasterizationScale = [UIScreen mainScreen].scale;
答案 0 :(得分:1)
您应该再设置一个图层属性 - shadowPath:
self.layer.shadowRadius = 5;
self.layer.shadowOpacity = 0.5;
self.layer.shadowOffset = CGSizeMake(0, 1);
self.layer.shadowColor = [UIColor blackColor].CGColor;
self.layer.shadowPath = [UIBezierPath bezierPathWithRoundedRect: self.bounds cornerRadius: self.layer.shadowRadius].CGPath;
此路径定义用于构造图层阴影的轮廓,而不是使用图层的合成Alpha通道。使用此属性显式指定路径通常可以提高渲染性能
答案 1 :(得分:0)
添加阴影作为图像,它的性能更好。您可以使用图像切片来帮助缩放图像。