ios - 自定义 UITableViewCell 中的默认删除按钮和图标
<p><p>我正在尝试更改默认按钮以删除表格 View 中的一行(当用户向左滑动时)。
<a href="/image/FiYgH.png" rel="noreferrer noopener nofollow">Changing the height of the default confirmation delete button</a> </p>
<p>同时我想在进入编辑模式时在单元格左侧添加自定义图像...
[更改进入编辑模式删除时的默认图标<a href="/image/rjSiu.png" rel="noreferrer noopener nofollow">2</a> </p>
<p>我的代码中包含:</p>
<pre><code>func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
return true
}
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
}
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> ? {
let delete = UITableViewRowAction(style: .destructive, title: "\u{267A}\n Delete") { (action, indexPath) in
tableView.isEditing = false
print("delete")
// delete item at indexPath
}
return
}
</code></pre>
<p>是否可以更改确认删除按钮的高度并为左侧图标添加自定义图像?</p>
<p>谢谢!
:)</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>您需要将 UIImage 设置为 UITableViewRowAction 的 backgroundColor。</p>
<pre><code>let someAction = UITableViewRowAction(style: .Default, title: "") { value in
println("button did tapped!")
}
someAction.backgroundColor = UIColor(patternImage: UIImage(named: "myImage")!)
</code></pre></p>
<p style="font-size: 20px;">关于ios - 自定义 UITableViewCell 中的默认删除按钮和图标,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/44882478/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/44882478/
</a>
</p>
页:
[1]