参考
参考
-
AlerView类上的一个BaseView上添加按钮 按钮在BaseView之外
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
UIView *view = [super hitTest:point withEvent:event];
CGPoint tempPoint = [self.closeBtn convertPoint:point fromView:self];
if ([self.closeBtn pointInside:tempPoint withEvent:event]) {
NSLog(@"---111111-");
return self.closeBtn;
}
NSLog(@"----222--");
return view;
}
-
// 在自定义UITabBar中重写以下方法,其中self.button就是那个希望被触发点击事件的按钮
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
UIView *view = [super hitTest:point withEvent:event];
if (view == nil) {
// 转换坐标系
CGPoint newPoint = [self.button convertPoint:point fromView:self];
// 判断触摸点是否在button上
if (CGRectContainsPoint(self.button.bounds, newPoint)) {
view = self.button;
}
}
return view;
}
-
-(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
UIView *view = [super hitTest:point withEvent:event];
if (view == nil) {
for (UIView *subView in self.subviews) {
CGPoint myPoint = [subView convertPoint:point fromView:self];
if (CGRectContainsPoint(subView.bounds, myPoint)) {
return subView;
}
}
}
return view;
}
网友评论