【发布时间】:2019-11-25 03:34:41
【问题描述】:
我有一个 UITableView,它有一个 UITableViewCells 列表,其中包含自定义角半径。滑动编辑时,e.i.删除/插入,圆角半径重置为0。
我尝试在编辑时设置圆角半径:
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
guard let cell = tableView.cellForRow(at: indexPath) as? HabitTableViewCell else { return }
cell.layer.cornerRadius = 13
if editingStyle == .delete {
controller.delete(habit: frc.object(at: indexPath))
}
}
我还尝试以类似的方式实现 willBeginEditingRowAt 以尝试使角半径保持不变。我尝试的最后一件事是在 trailingSwipeActionsConfigurationForRowAt 中创建自定义 UIContextualAction,但它并没有改变任何东西。
大约四年前有一个similar question asked,但从未找到最终的解决方案。感谢您提供任何帮助或见解!
【问题讨论】:
-
你为什么不用'layoutSubviews'功能在'UITableViewCell'内制作'cornerRadius'?
标签: ios swift xcode uitableview cornerradius