UITableViewCell Swipe for Drawer

前端 未结 5 620
醉梦人生
醉梦人生 2021-02-04 15:31

This is really more of a curiosity than a hard coding question.

Both Facebook and Twitter both have a feature where swiping a UITableViewCell animates the cell off the s

5条回答
  •  孤城傲影
    2021-02-04 16:30

    As a UITableViewCell is just a UIView, you can use this fact to basically do anything you like with it.

    To solve your problem, I'd attach a UISwipeGestureRecognizer to detect the swipe and then animate the view to a different state.

    For example, you could create a custom cell that has it's content view laying above the "actions view". Whenever there is a swipe, you use a UIView animation to move the content view aside and show the action view with a couple of buttons instead. In a custom UITableViewCell you could add a delegate protocol to have the pressed action and the cell being sent to the delegate, i.e. your controller. There you'd trigger what ever there is to trigger and then transition the cell out of the state.

提交回复
热议问题