如何制作可滑动的 UItableview 标题以显示像单元格一样的删除按钮
我有一个自定义标题,它是 UITableViewHeaderFooterView
的子类我想将类似于 UITableViewCell
的删除按钮添加到此标题,我已经通过互联网找到了一些开源库来创建可滑动的单元格,它只扩展了 UITableviewCell
的功能,实际上我暂时不需要,
I have a custom header which is sub class of UITableViewHeaderFooterView
I want to add the delete button similar to UITableViewCell
to this header,
I have gone through the internet and found some open source libraries to create swipeable cell which only extend the functionality of UITableviewCell
which actually I don't need for the time,
我真正想要的是创建一个可滑动的标题视图以在滑动时显示删除按钮.
What I actually want is to create a swipeable header View to show the delete button on swipe.
对此没有现成的解决方案.但是我们仍然可以通过我们自己的自定义删除按钮来完成.这个想法是在标题内容视图下有一个 UIButton
并在滑动标题时为其设置动画.
There is not out of the box solution for this. However we can still do it by our own custom delete button. The idea is to have a UIButton
under the header content view and animate it when swiping on header.
Ray Wenderlichs 有一个关于 如何使用动作制作可滑动的表格视图单元对 UITableViewHeaderFooterView
使用相同的逻辑,你就可以开始了.
Ray Wenderlichs has a great tutorial for How To Make A Swipeable Table View Cell With Actions
Use the same logic for UITableViewHeaderFooterView
and you are good to go.