just hijack
it,
func swizzle() {
guard let cls = NSClassFromString("UITextSelectionView") else { return }
let originalSelector = NSSelectorFromString("updateSelectionRects")
let swizzledSelector = #selector(UIView.updateSelectionRectsHijack)
let originMethod = class_getInstanceMethod(cls, originalSelector)
let swizzleMethod = class_getInstanceMethod(UIView.self, swizzledSelector)
if let swizzledMethod = swizzleMethod, let originalMethod = originMethod{
method_exchangeImplementations(originalMethod, swizzledMethod)
}
}
extension UIView{
@objc func updateSelectionRectsHijack(){ }
}
swizzle()
should be call once only.
How I know UITextSelectionView
?
Check View Hierarchy
,

How I know method updateSelectionRects
?
via runtime
,
import ObjectiveC
,
then,
var count: UInt32 = 0
guard let methodArr = class_copyMethodList(NSClassFromString("UITextSelectionView"), &count) else { return }
let cnt = Int(count)
for i in 0..<cnt{
let method = methodArr[i]
let name = method_getName(method)
if let type = method_getTypeEncoding(method){
print(name, String(utf8String: type) ?? " _ | _ ")
}
}