美文网首页
uiview hitTest

uiview hitTest

作者: 那是什么 | 来源:发表于2016-11-09 10:36 被阅读29次

    button 超出superView 无法点击解决方法

    - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {

    UIView *result = [super hitTest:point withEvent:event];

    CGPoint buttonPoint = [self.button convertPoint:point fromView:self];

    if ([self.button pointInside:buttonPoint withEvent:event]) {

    return self.button;

    }

    return result;

    }

    透明View遮盖无法点击

    - (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent *)event{

    UIView *hitView = [super hitTest:point withEvent:event];

    if(hitView == self){

    return nil;

    }

    return hitView;

    }

    相关文章

      网友评论

          本文标题:uiview hitTest

          本文链接:https://www.haomeiwen.com/subject/nhizuttx.html