iPhone: Click view behind transparent UIScrollView

蓝咒 提交于 2019-12-03 10:54:29

What we did was to subclass UIScrollView and implement logic that passes responsibility down to views under it, if the touch happens inside of the transparent area.

In our case the transparent area is defined by contentOffset of 120 on Y axis, meaning our content starts 120 points below the start of the UIScrollView, and the code looks like this:

- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
{
    if (self.contentOffset.y < 0 && point.y < 0.0) {
        return NO;
    } else {
        return YES;
    }
}

Obviously this response is well past its prime but hopefully this is helpful to anyone searching for a solution.

Basically, it's up to you to determine what touch events you care to forward to another responder. If you simply want to forward all touch events, just remove that if statement in the code you posted so the next responder will receive all the touch events.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!