加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

swift中tableview给cell添加左划菜单

发布时间:2020-12-14 06:10:24 所属栏目:百科 来源:网络整理
导读:直接在文件中加入函数就行 func tableView ( _ tableView: UITableView,editActionsForRowAt indexPath: IndexPath) - [ UITableViewRowAction ]? { //设计左划菜单,添加和打招呼 let more = UITableViewRowAction (style: .normal,title: "添加" ) { actio
 
直接在文件中加入函数就行
func tableView(_ tableView: UITableView,editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
    //设计左划菜单,添加和打招呼
    let more = UITableViewRowAction(style: .normal,title: "添加") { action,index in
        //第一个按钮点击后操作放这里
    }
    //设置颜色
    more.backgroundColor = UIColor.lightGray

    let favorite = UITableViewRowAction(style: .normal,title: "打招呼") { action,index in
        //第二个按钮操作

    }
    favorite.backgroundColor = UIColor.orange
    //返回两个按钮
    return [favorite,more]
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读