I\'ve read some posts on this, but still can\'t get the answer to my question.
I have a disclosure indicator.
Swift 3 - a simple Table View class that can show a disclosure indicator or not using the showsDisclosure
boolean when configuring the cell. right now the disclosure arrow tint color is hard coded, but your color choice could easily be passed in through the configure function as well if you wanted a more reusable cell.
Note that the 'chevron' image is set to be a template image in the asset catalog, which means that it can be tinted a color. You can alternatively make a UIImage into a template image in code like so: UIImage(named: "chevron")?.withRenderingMode(.alwaysTemplate)
class HeaderTableViewCell: UITableViewCell {
@IBOutlet weak var sectionTitle: UILabel!
override func awakeFromNib() {
sectionTitle.textColor = .black
}
func configure(title: String, showsDisclosure: Bool = false) {
self.sectionTitle.text = title
if showDisclosure {
//add custom disclosure arrow
let chevronImgView = UIImageView(image: UIImage(named: "chevron"))
chevronImgView.tintColor = .red
self.accessoryType = .disclosureIndicator
self.accessoryView = chevronImgView
} else {
self.accessoryType = .none
self.accessoryView = nil
}
}
}