I have the following table that up to now looks like this:
What you see here are the titles of the sections, with the accordion effect, what I would like to be able to put an image next to each title, to have an effect like this
Investigating I saw that I can dynamically in the method
viewForHeaderInSection
add this image my code so far is
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let view = UIView()
view.backgroundColor = UIColor.white
view.addBottomBorder(Utils.Color.COLOR_SEPARACIONES, height: 2.5, separation: 0)
let tap = UITapGestureRecognizer.init(target: self, action: #selector(tapOnHeader(_:)))
tap.numberOfTapsRequired = 1
view.tag = section
view.addGestureRecognizer(tap)
let label : UILabel = UILabel()
label.text = sectionTitles[section]
label.frame = CGRect(x: 20, y: 5, width: 200, height: 30)
label.textColor = Utils.Color.COLOR_2B5034
view.addSubview(label)
return view
}
I am not sure how I can dynamically create an image and add the contrains so that it is centered with respect to the label, thank you already, I use swift 4