简体   繁体   English

更改 UITableViewCell 上的一个附件视图的大小

[英]Change the size of an accessoryView on UITableViewCell

如何使用 Swift 更改UITableViewCell上的accessoryView UITableViewCell的大小?

This can be done in the UITableView 's cellForRowAt method:这可以在UITableViewcellForRowAt方法中完成:

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
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM