How do you change the size of an accessoryView
on a UITableViewCell
using Swift?
1 Answer
This can be done in the UITableView
's cellForRowAt
method:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "customCellID", for: indexPath) as! CustomTableCell
cell.accessoryView = UIImageView(image: "imageName")
// This is where the magic happens
cell.accessoryView?.bounds = CGRect(x: 0, y: 0, width: 50, height: 50)
return cell
}