在透明的UIView中重寫(xiě)下面這個(gè)函數(shù)即可:
OC:
- (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent *)event{
UIView *hitView = [super hitTest:point withEvent:event];
if(hitView == self){
return nil;
}
return hitView;
}
Swift:
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
let hitView = super.hitTest(point, with: event)
if(hitView == self){
return nil
}
return hitView
}
純屬個(gè)人筆記跷究,如有錯(cuò)誤,歡迎指出敲霍。