I am using TableView and on swiping the cell with editing style .delete but the size of cell has been customized as per the requirements of app. the delete Button height is little bigger how can we customize that.
Check the screenshot please:
I am using TableView and on swiping the cell with editing style .delete but the size of cell has been customized as per the requirements of app. the delete Button height is little bigger how can we customize that.
Check the screenshot please:
@averydev update my code in swift you can try this
class CustomTableViewCell: UITableViewCell {
override func didTransition(to state: UITableViewCellStateMask) {
super.willTransition(to: state)
if state == .showingDeleteConfirmationMask {
let deleteButton: UIView? = subviews.first(where: { (aView) -> Bool in
return String(describing: aView).contains("Delete")
})
if deleteButton != nil {
deleteButton?.frame.size.height = 50.0
}
}
}
}
Currently, in iOS 16, the way to do it is by calling the willBeginEditingRowAt table view delegate method in your view controller class and changing the height property of the UISwipeActionPullView. I'm going to refer to your view controller class as NotesViewController here:
class NotesViewController: UIViewController {
...
extension NotesViewController: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, willBeginEditingRowAt indexPath: IndexPath) {
// Get the subviews of the table view
let subviews = tableView.subviews
// Iterate through subviews to find _UITableViewCellSwipeContainerView
for subview in subviews {
if String(describing: type(of: subview)) == "_UITableViewCellSwipeContainerView" {
// Get the UISwipeActionPullView
if let swipeActionPullView = subview.subviews.first {
if String(describing: type(of: swipeActionPullView)) == "UISwipeActionPullView" {
// Set the height of the swipe action pull view (set to whatever height your custom cell is)
swipeActionPullView.frame.size.height = 50
}
}
}
}
}
}
}