在我的 UICollectionView 中向下滚动时,它会滞后,并由此导致:
imageCell?.backgroundColor = UIColor.whiteColor()
imageCell?.layer.masksToBounds = false
imageCell?.layer.shadowOpacity = 0.5
imageCell?.layer.shadowRadius = 5.0
imageCell?.layer.shadowOffset = CGSizeZero
imageCell?.layer.shadowColor = UIColor.grayColor().CGColor
imageCell 为单元格名称:
let imageCell = collectionView.dequeueReusableCellWithReuseIdentifier("imageCell", forIndexPath: indexPath) as? CollectionViewCell
有什么建议我应该做什么?
最佳答案
使用阴影时,如果您知道形状,最好指定 shadowPath
。
imageCell?.layer.shadowPath = UIBezierPath(rect: imageCell?.frame ?? CGRectZero).CGPath
Specifying an explicit path usually improves rendering performance.
关于ios - UICollectionViewCell 阴影导致小延迟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34405740/