gpt4 book ai didi

ios - 滚动时 CollectionView 滞后

转载 作者:行者123 更新时间:2023-11-29 00:06:19 25 4
gpt4 key购买 nike

先生,我是初学者。我无法理解这一点。滚动 collectionView 时我遇到了延迟。我删除了 Cell-shadow 然后滞后消失了。但我想添加阴影。我的 cellforItem 代码是:

- (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;

最佳答案

您应该设置图层的另一个属性 - 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 channel 。使用此属性显式指定路径通常会提高渲染性能

关于ios - 滚动时 CollectionView 滞后,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47966097/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com