3

How do you change the size of an accessoryView on a UITableViewCell using Swift?

1 Answer 1

3

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
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.