ios cell selectedBackgroundView alpha 不起作用

要实现如图自定义 cell 点击时的半透明背景色.

在 cellForRow 中写如下代码不起作用:

let bgView = UIView(frame: cell.bounds)
bgView.backgroundColor = .white
bgView.alpha = 0.1
cell.selectedBackgroundView = bgView

应改为

let bgView = UIView(frame: cell.bounds)
bgView.backgroundColor = RGBA(r: 255, g: 255, b: 255, a: 0.1)
cell.selectedBackgroundView = bgView
发布了79 篇原创文章 · 获赞 9 · 访问量 7万+

猜你喜欢

转载自blog.csdn.net/LeeCSDN77/article/details/95459448
今日推荐