Changing background color of selected cell?

后端 未结 30 2968
太阳男子
太阳男子 2020-11-29 00:22

Does anyone know how to change the background color of a cell using UITableViewCell, for each selected cell? I created this UITableViewCell inside the code for TableView.

30条回答
  •  我在风中等你
    2020-11-29 00:52

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
    
        if selected {
            self.contentView.backgroundColor = .black
        } else {
            self.contentView.backgroundColor = .white
        }
    }
    

提交回复
热议问题