我想在顶部添加透明的UIView,并在hitTest:withEvent函数的帮助下将触摸事件转发到UIButton和UISlider的子视图。
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
CGPoint hitPoint = [underneathView convertPoint:point fromView:self];
if ([underneathView pointInside:hitPoint withEvent:event]){
NSLog(@"UnderneathView");
return underneathView;
}
NSLog(@"not UnderneathView");
return [super hitTest:point withEvent:event];
}
但我不确定如何正确使用它。请提供一些示例/教程或建议我正确的方法。
由于