首页 > 其他 > 详细

UITableView定制左滑效果

时间:2017-01-14 10:13:16      阅读:232      评论:0      收藏:0      [点我收藏+]

技术分享
UITableViewRowAction类

object defines a single action to present when the user swipes horizontally in a table

类的属性

  • style: UITableViewRowActionStyle
    按钮的style,defaultnormal效果如上图
  • title: String?
    按钮的标题啦
  • backgroundColor: UIColor? 按钮的颜色

初始化方法

convenience init(style: UITableViewRowActionStyle, title: String?, handler: (UITableViewRowAction, IndexPath) -> Void)

handler即使点击时调用的方法。

如何实现效果

  1. 初始化UITableViewRowAction

        let action1 = UITableViewRowAction.init(style: .Normal, title: "normal") { (action, path) in
        }
        let action2 = UITableViewRowAction.init(style: .Default, title: "default") { (action, path) in
            self.titles.removeAtIndex(0)
            self.tableView?.deleteRowsAtIndexPaths([path], withRowAnimation: .Fade)
        }
        self.actions.insert(action1, atIndex: 0)
        self.actions.insert(action2, atIndex: 1)
    ```
    
  2. 实现代理方法

    func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? {
         return self.actions
    }
    

UITableView定制左滑效果

原文:http://www.cnblogs.com/huahuahu/p/UITableView-ding-zhi-zuo-hua-xiao-guo.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!