在我的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
Apple mentions
指定显式路径通常可以提高渲染性能。
关于ios - UICollectionViewCell阴影导致小滞后,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34405740/