Custom UI TableViewCell selected backgroundcolor swift

前端 未结 11 971
盖世英雄少女心
盖世英雄少女心 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条回答
  •  猫巷女王i
    2020-12-28 17:16

    None of above answers worked, so I try mine and it worked: Here it is:-

    1. In your cell create function like this.
    func reloadcell() {
        if isSelected {
            conView.backgroundColor = .yellow
        } else if isHighlighted {
            conView.backgroundColor = .yellow
        } else {
            conView.backgroundColor = .clear
        }
    }
    

    and call that function in layoutsubviews and in your didselect method

提交回复
热议问题