【发布时间】:2017-12-03 14:55:55
【问题描述】:
我创建了一个集合视图,其中单元格内部有一个视图。视图的 alpha 值为 0.65。当我滚动时,视图变得更亮。也许这些视图会堆叠在一起?
我的代码:
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! LevelStufenCell
cell.levelViewBack = UIView()
cell.levelViewBack.frame = CGRect(x: 0, y: 0, width: cell.frame.height, height: cell.frame.width)
cell.levelViewBack.layer.cornerRadius = cell.levelViewBack.frame.height * (36 / 198)
cell.levelViewBack.backgroundColor = UIColor.white
cell.levelViewBack.alpha = 0.65
cell.insertSubview(cell.levelViewBack, at: 10)
return cell
}
【问题讨论】:
-
你有什么理由不在界面生成器中添加子视图吗?
标签: ios swift uicollectionview