iOS UIButton超出父视图无法点击解决方法

来源:互联网 发布:什么是overlay网络 编辑:程序博客网 时间:2024/06/07 14:55

有时候父子View的frame超出了父View的范围。这时候UIButton等子view就无法点击了。

以UIButton为例,如果UIButton 是 UIView的子视图,但是UIButton超出了UIView的边界,导致超出的部分无法点击可以用下面的方法来实现UIButton的点击:

- (UIView *)clickTest:(CGPoint)point withEvent:(UIEvent *)event {    UIView *result = [super hitTest:point withEvent:event];    CGPoint butttonClickPoint = [self.button convertPoint:point fromView:self];    if ([self.button pointInside:buttonPoint withEvent:event]) {        return self.button;    }    return result;}
阅读全文
1 0
原创粉丝点击