import UIKit
class RefreshAndEditingTableView: RefreshTableView {
override func layoutSubviews() {
super.layoutSubviews()
if #available(iOS 11.0, *) {
for subview in self.subviews where subview.isKind(of: NSClassFromString("UISwipeActionPullView")!) {
subview.backgroundColor = RGBA(242, g: 242, b: 242, a: 1)
for view in subview.subviews where view.isKind(of: NSClassFromString("UISwipeActionStandardButton")!) {
view.backgroundColor = RGBA(242, g: 242, b: 242, a: 1)
let deleteBtn = setupDeleteBtn(frame: CGRect(x: 0, y: 0, width: 80, height: view.bounds.height))
view.addSubview(deleteBtn)
view.bringSubviewToFront(deleteBtn)
}
}
} else { // IOS 10以及以下
for subview in subviews where subview.isKind(of: NSClassFromString("UITableViewCellDeleteConfirmationView")!) {
subview.backgroundColor = RGBA(242, g: 242, b: 242, a: 1)
for view in subview.subviews where view.isKind(of: UIButton.self) {
view.backgroundColor = RGBA(242, g: 242, b: 242, a: 1)
let deleteBtn = setupDeleteBtn(frame: view.frame)
view.addSubview(deleteBtn)
view.bringSubviewToFront(deleteBtn)
}
}
}
}
private func setupDeleteBtn(frame: CGRect) -> UIButton {
let deleteBtn = UIButton(type: .custom)
deleteBtn.frame = frame
deleteBtn.backgroundColor = RGBA(242, g: 242, b: 242, a: 1)
deleteBtn.setImage(UIImage(named: "btn_home_footmark_delete"), for: .normal)
deleteBtn.imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
return deleteBtn
}
}
网友评论