ios – 如何为UITableView中的Index Bar部分设置透明背景?

前端之家收集整理的这篇文章主要介绍了ios – 如何为UITableView中的Index Bar部分设置透明背景?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
如何在UITableView中为部分索引栏设置透明背景?

我试过了:

tableView.sectionIndexBackgroundColor = .clearColor()

但酒吧的背景为浅灰色

编辑
我试图改变tableview的背景颜色,但它似乎没有影响.

tableView.backgroundView = UIView.init()
  tableView.backgroundColor = .blackColor() // tried .clearColor() too.

EDIT2

tableView.sectionIndexBackgroundColor = UIColor(white: CGFloat(1.0),alpha: CGFloat(0.5)) // change the alpha and check once

我也尝试过使用alpha值的颜色.我可以使背景半透明(参见上面的行代码).但是,如果我将alpha设置为0.0以使其完全透明,我将再次获得浅灰色背景.

解决方法

tableView.sectionIndexBackgroundColor = .clear完美无缺

here's example

猜你在找的iOS相关文章