I have a UIButton
in my tableView
, I am trying to change it's image, but when I run the app - in the simulator and in the iPhone, it shows nothing.
My image format is PNG.
Here is my code in cellForRowAt
:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! notesTableViewCell
cell.buttonImage.setImage(UIImage(named: "imagetest2.png"), for: UIControlState.normal)
cell.buttonImage.imageView?.contentMode = .scaleAspectFit
cell.buttonImage.tag = indexPath.row
cell.buttonImage.addTarget(self, action: #selector(buttonImageFunc), for: .touchUpInside)
cell.selectionStyle = UITableViewCellSelectionStyle.none
return cell
}
This is notesTableViewCell
code:
class notesTableViewCell: UITableViewCell {
@IBOutlet var buttonImage: UIButton!
override func awakeFromNib() {
super.awakeFromNib()
}