我想将单元格附件类型设置为我自己的自定义图片
let cell = tableView.cellForRow(at: indexPath)
cell?.accessoryType = UIImage(named: "heart.pdf")
我该如何在Swift中做到这一点?
致谢
答案 0 :(得分:2)
您可以在表格视图单元的附件视图的帮助下添加自己的图像,如下所示。
let cell = tableView.cellForRow(at: indexPath)
let imgView = UIImageView(frame: CGRect(x: 0, y: 0, width: 30, height: 30))
imgView.image = UIImage(named: "{your image name}")!
cell.accessoryView = imgView
答案 1 :(得分:0)
您可以通过设置单元格附件视图来设置附件类型,
// first create UIImageView
var imageView = UIImageView(frame: CGRect(x: 20, y: 20, width: 100, height: 320))// change your height/width as per your needs.
imageView.image = UIImage(named: "yourImage.jpg")
//then set it as cellAccessoryType
yourCell.accessoryView = imageView