我有UICollectionView
包含带有大图像的单元格。滚动很顺利,直到我UIVisualEffectView
向每个单元格添加(小)。现在,滚动性能很糟糕。
以下是与该代码相关的所有UIVisualEffectView
代码:
class ThemeCardCell: UICollectionViewCell {
private let priceTagEffectView = UIVisualEffectView()
override func layoutSubviews() {
super.layoutSubviews()
if priceTagEffectView.superview == nil {
priceTagEffectView.effect = UIBlurEffect(style: UIBlurEffectStyle.Light)
priceTagEffectView.frame = CGRect(x: bounds.width - priceTagMargin.width - 80, y: priceTagMargin.height, width: 80, height: 40)
priceTagEffectView.opaque = true
addSubview(priceTagEffectView)
}
}
}
我可以做些什么来提高滚动性能?