删除按钮未显示在带有圆角的 UITableViewCell 上 [英] Delete button not showing on UITableViewCell with rounded corners

查看:55
本文介绍了删除按钮未显示在带有圆角的 UITableViewCell 上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 tableview 中,我的 tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) 中有逻辑来确定单元格的顶部、底部是否有圆角圆角.

In my tableview, I have logic in my tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) to determine if a cell has rounded corners on top, bottom, or no rounded corners at all.

override func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {

        if indexPath.row == 0 {
            // round top 2 corners
            let maskLayer = CAShapeLayer()
            maskLayer.path = UIBezierPath(roundedRect: cell.bounds, byRoundingCorners: [UIRectCorner .TopLeft, UIRectCorner .TopRight], cornerRadii: CGSizeMake(4, 4)).CGPath
            cell.layer.mask = maskLayer
        }

        if indexPath.section != 1 {

            if indexPath.row == self.tableView.numberOfRowsInSection(indexPath.section) - 1 {
                let maskLayer = CAShapeLayer()
                maskLayer.path = UIBezierPath(roundedRect: cell.bounds, byRoundingCorners: [UIRectCorner .BottomLeft, UIRectCorner .BottomRight], cornerRadii: CGSizeMake(4, 4)).CGPath
                cell.layer.mask = maskLayer
            }
        }

    }

这可行,但是在我对 tableview 实施编辑后,删除按钮发生了奇怪的事情.

This works, but after I have implemented editing into the tableview, strange things happen to the delete button.

使用圆角代码:

当我移除圆角时:

这真的让我很困惑,因为我不确定自己做错了什么.有人可以帮忙吗?

This really confuses me because I'm not sure what I'm doing wrong. Can anyone help?

推荐答案

最简单的方法是在 uitableviewcell 上添加一个带圆角的全尺寸视图.

The easy way is add a full size view with round corner on the uitableviewcell.

这篇关于删除按钮未显示在带有圆角的 UITableViewCell 上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆