ios - 如何将 cell.accessoryType 设置为图像?
问题描述
我想将电池配件类型设置为我自己的自定义图像
let cell = tableView.cellForRow(at: indexPath)
cell?.accessoryType = UIImage(named: "heart.pdf")
我将如何在 Swift 中做到这一点?
问候
解决方案
您可以在表格视图单元格的附件视图的帮助下添加自己的图像,如下所示。
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
推荐阅读
- python - 使用 Holoviews 构建和弦图:没有错误,但也没有保存图像
- java - 为什么这段代码在 TextView 中没有返回任何值 无法从 json 获取任何值
- python - 为什么我的代码中没有为我的句子生成解析树?
- wso2 - 在配置 wso2 ei 和 ei 分析时,出现以下异常
- vue.js - 是否可以将 bootbox 与 Vue.js 一起使用?
- wpf - 在 WPF 中缓存动态数据集
- java - 错误启动应用程序无法执行目标 org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
- c# - 将属性添加到 MVC 选择列表
- java - 如何在种子堆栈中使用 Group By?
- reactjs - 无法在 React.js 中添加活动类