Custom UI TableViewCell selected backgroundcolor swift

前端 未结 11 945
盖世英雄少女心
盖世英雄少女心 2020-12-28 16:51

I am trying to change the appearance of a custom selected TableViewCell using Swift.

Do I need to do it via the designer or programmatically?

I tried the fol

11条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-28 17:09

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        updateUI(isSelected: selected)
    }
    
    private func updateUI(isSelected: Bool){
       label.textColor = isSelected ? .red : .green
       //etc..
    }
    

提交回复
热议问题