iOS 10: UITableViewCell's delete button custom height

前端 未结 4 743
既然无缘
既然无缘 2021-01-15 04:44

Using custom UITableViewCell, I\'m trying to change the height of tableViewCell\'s delete button. I\'ve tried all the solutions available here on SO.

Everyone has me

4条回答
  •  情歌与酒
    2021-01-15 05:09

    Same code but works with Swift 5 and iOS 12+

     func tableView(_ tableView: UITableView, willBeginEditingRowAt indexPath: IndexPath) {
            for subview in tableView.subviews {
                if NSStringFromClass(type(of: subview)) == "UISwipeActionPullView",
                    let button = subview.subviews.first,
                    NSStringFromClass(type(of: button)) == "UISwipeActionStandardButton" {
    
                    button.backgroundColor = .red
                    button.layer.cornerRadius = 8
                    button.layer.masksToBounds = true
                    (button as? UIButton)?.contentHorizontalAlignment = .center
                    (button as? UIButton)?.contentVerticalAlignment = .center
                    (button as? UIButton)?.titleEdgeInsets = UIEdgeInsets(top: 6, left: 0, bottom: 0, right: 0)
                    button.superview?.backgroundColor = UIColor(white: 0.97, alpha: 1)
                    button.superview?.layoutIfNeeded()
                }
            }
        }
    

提交回复
热议问题