iOS 10: UITableViewCell's delete button custom height

前端 未结 4 708
既然无缘
既然无缘 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:31

    Swift 5, this works for iOS12, iOS13 and iOS14

      func tableView(_ tableView: UITableView, willBeginEditingRowAt indexPath: IndexPath) {
        // for iOS13, iOS14
        if let swipeContainerView = tableView.subviews.first(where: { String(describing: type(of: $0)) == "_UITableViewCellSwipeContainerView" }) {
          if let swipeActionPullView = swipeContainerView.subviews.first, String(describing: type(of: swipeActionPullView)) == "UISwipeActionPullView" {
            swipeActionPullView.frame.size.height -= 10
          }
        }
    
        // for iOS12
        tableView.subviews.forEach { subview in
          if String(describing: type(of: subview)) == "UISwipeActionPullView" {
            subview.frame.size.height -= 10
          }
        }
      }
    

提交回复
热议问题