iOS hitTest:withEvent: 笔记

前言

处理自定义视图内
超出视图范围的子视图事件


重写

#pragma mark --- override
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
    if (!self.isUserInteractionEnabled || self.isHidden || self.alpha < 0.01) {
        return nil;
    }

    for (UIView *view in [self.subviews reverseObjectEnumerator]) {
        CGPoint hitPoint = [view convertPoint:point fromView:self];
        UIView *target = [view hitTest:hitPoint withEvent:event];
        if (target) {
            return target;
        }
    }
    return nil;
}

一行代码搞定视图圆角

https://github.com/xjh093/JHViewCorner


你可能感兴趣的:(iOS)