Reputation: 33
I have customize Swipe delete button till swift3 [ios 9].
I have tried this code for ios 9 in swift3
func setSwipeDeletebutton(cell : UITableViewCell, BackView : UIView) {
//Customize Delete button
for subview in cell.subviews {
subview.backgroundColor = UIColor.clear
for sub in subview.subviews {
if String(describing: sub).range(of: "UITableViewCellActionButton") != nil {
sub.backgroundColor = UIColor.white
var newframe = sub.frame
newframe.size.height = BackView.frame.size.height
sub.frame = newframe
sub.SetUpView()
for view in sub.subviews {
if String(describing: view).range(of: "UIButtonLabel") != nil {
if let label = view as? UILabel {
label.textColor = SharedInstance.hexStringToUIColor(hex: Color.TodayActivityColor.Type_LEAVE)
}
}
}
}
}
}
}
Now, as a change in ios 11, I can not customize swipe delete button using this code.
I have tried to set image as swipe delete button, but it's not set properly because I also want shadow to that delete button.
Can anyone suggest that how can I customize the swipe delete button using swift4?
Upvotes: 2
Views: 534
Reputation: 2329
You are accessing subviews by using:
String(describing: sub).range(of: "UITableViewCellActionButton")
And
String(describing: view).range(of: "UIButtonLabel")
This is not advisable by apple.
However, to debug this issue open your view hierarchy while the table view row action / drawer is open.
You should see the view you wish to alter, in the hierarchy.
Then change your Strings as required:
String(describing: sub).range(of: "UISwipeActionPullView")
UISwipeActionPullView
may not be what you need but the concept is the same.
Upvotes: 4