在我的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
有什么建议我应该做什么?
答案 0 :(得分:1)
使用阴影时,如果您知道形状,最好指定shadowPath
。
imageCell?.layer.shadowPath = UIBezierPath(rect: imageCell?.frame ?? CGRectZero).CGPath
指定显式路径通常可以提高渲染性能。
答案 1 :(得分:0)
但真正有所作为的是光栅化