Altering the background color of cell.accessoryView and cell.editingAccessoryView

前端 未结 5 805
被撕碎了的回忆
被撕碎了的回忆 2020-12-05 13:45

Whenever I add an accessoryView to my UITableViewCell, it doesn\'t carry the background color across? I\'m setting a UISwitch as my accessoryView, and the color I have set i

5条回答
  •  执念已碎
    2020-12-05 13:59

    If you want to blend the accessory view background color with the background color of the cell, in iOS8 and Swift this worked like a charm in the tableView(_, cellForRowAtIndexPath:) method:

    let color = cell.contentView.backgroundColor
    cell.backgroundColor = color
    

提交回复
热议问题