zoukankan      html  css  js  c++  java
  • iOS笔记【单元格右滑手势】 2017-09-09

    // 响应单元格右滑手势
    override func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
            let actionShare = UITableViewRowAction(style: .normal, title: "分享") { (_,IndexPath) in
                // 定义滑动菜单样式和标题
                let actionSheet = UIAlertController(title: "分享到", message: nil, preferredStyle: .actionSheet)
                // 定义按钮
                let optionQQ = UIAlertAction(title: "QQ", style: .default, handler: nil)
                let optionWeiXin = UIAlertAction(title: "微信", style: .default, handler: nil)
                let optionCancel = UIAlertAction(title: "取消", style: .cancel, handler: nil)
                // 把option操作添加到actionSheet中
                actionSheet.addAction(optionQQ)
                actionSheet.addAction(optionWeiXin)
                actionSheet.addAction(optionCancel)
                // 显示
                self.present(actionSheet, animated: true, completion: nil)
            }
            // 配置按钮颜色
            actionShare.backgroundColor = UIColor.orange
            let actionDel = UITableViewRowAction(style: .destructive, title: "删除") { (_, IndexPath) in
                // 删除相对应的每行数据
                self.areaImages.remove(at: indexPath.row)
                self.areaProvice.remove(at: indexPath.row)
                self.areas.remove(at: indexPath.row)
                self.areaType.remove(at: indexPath.row)
                self.visted.remove(at: indexPath.row)
                // Delete the row from the data source
                tableView.deleteRows(at: [indexPath], with: .fade)
    
            }
            
            let actionTop = UITableViewRowAction(style: .default, title: "置顶") { (_, _) in
                
            }
            actionTop.backgroundColor=UIColor(red: 245/255, green: 199/255, blue: 221/255, alpha: 1)
            
            
            // 返回滑动子菜单数组
            return [actionShare,actionDel,actionTop]
        }
    
  • 相关阅读:
    周记(2015-11-30 -- 2015-12-05)
    周记(2015-11-22 -- 2015-11-27)
    周记(2015-11-15 -- 2015-11-20)
    周记(2015-11-01 -- 2015-11-06)
    设备与主机的攻击日志类型分析总结
    OWASP十大攻击类型详解
    乌云TOP 10 简单介绍
    《启示录》读书笔记三
    百度地图和定位
    获取Android studio的SHA1值
  • 原文地址:https://www.cnblogs.com/lizhipengvvip/p/7499658.html
Copyright © 2011-2022 走看看