Ios 滑动删除按钮swift的自定义高度

Ios 滑动删除按钮swift的自定义高度,ios,iphone,swift,uitableview,Ios,Iphone,Swift,Uitableview,我有定制的表格单元格。每个细胞有不同的高度。我想给滑动删除按钮的单元格高度 我在手机里用过view。视图高度为单元格高度-16。上下边距8 所以,请帮我做这件事。在自定义单元格Swift类中使用此代码 override func layoutSubviews() { let fltHeight:CGFloat = 46 var subviews: [Any] = self.subviews let subview: UIView? = subviews[0] as? U

我有定制的表格单元格。每个细胞有不同的高度。我想给滑动删除按钮的单元格高度

我在手机里用过view。视图高度为单元格高度-16。上下边距8


所以,请帮我做这件事。

在自定义单元格Swift类中使用此代码

override func layoutSubviews() {
    let fltHeight:CGFloat = 46
    var subviews: [Any] = self.subviews
    let subview: UIView? = subviews[0] as? UIView
    if NSClassFromString("UITableViewCellDeleteConfirmationView") != nil {
        if (subview?.isKind(of: NSClassFromString("UITableViewCellDeleteConfirmationView")!))! {
            let deleteButtonView: UIView? = (subview?.subviews[0])
            var buttonFrame: CGRect? = deleteButtonView?.frame
            buttonFrame?.origin.x = (deleteButtonView?.frame.origin.x)!
            buttonFrame?.origin.y = (deleteButtonView?.frame.origin.y)!
            buttonFrame?.size.width = (deleteButtonView?.frame.size.width)!
            buttonFrame?.size.height = fltHeight
            deleteButtonView?.frame = buttonFrame!

            // Placing at the center of the cell.
            subview?.frame = CGRect(x: CGFloat((subview?.frame.origin.x)!),
                                    y: CGFloat((subview?.frame.origin.y)! + ((subview?.frame.size.height)!-fltHeight)/2),
                                    width: CGFloat((subview?.frame.size.width)!),
                                    height: CGFloat(fltHeight))
            deleteButtonView?.clipsToBounds = true
            subview?.clipsToBounds = true
        }
    }
}