简体   繁体   中英

Change the size of an accessoryView on UITableViewCell

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

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
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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