• 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]
        }
    
  • 相关阅读:
    NYOJ 205
    NYOJ 187
    NYOJ 105
    NUOJ 88
    NYOJ 70
    LL(1)算法
    MATLAB的一些基础知识
    Ubuntu raid5+lvm实验
    空间滤波
    认识weblogic的各个机构
  • 原文地址:https://www.cnblogs.com/lizhipengvvip/p/7499658.html
Copyright © 2020-2023  润新知