IOS hitTest 详解

发布时间:2019-08-06 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了IOS hitTest 详解脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

屏幕上的触摸事件,如果知道是那个视图来响应该事件就是由这个方法来确定

定义

Return Value
The view object that is the farthest descendent the current     view and contains point. Returns nil if the point lies completely     outside the receiver’s view hierArchy.

返回离自己最远的子视图,事件坐标在这个视图内

我认为意思应该是找到最精确的那个位置(view),并且可以通过这个方法来完成一些自定义,比如某个view挡住了另外一个view可以绕过。

具体

This method traverses the view hierarchy by calling the pointInside:wIThEvent: method of each subview to determine which subview should receive a touch event. If pointInside:withEvent: returns YES, then the subview’s hierarchy is similarly traversed until the frontmost view containing the sPEcified point is found. If a view does not contain the point, its branch of the view hierarchy is ignored. You rarely need to call this method yourself, but you might override it to hide touch events From subviews.

这个方法会在子视图上调用pointInside:withEvent 如果返回YES 则继续最后。
如果NO就中断绕过。

This method ignores view objects that are hidden, that have disabled user interactions, or have an alpha level less than 0.01. This method does not take the view’s content into account when determining a hit. Thus, a view can still be returned even if the specified point is in a transparent portion of that view’s content.

如果视图设置为不交互或者透明度小于0.01该方法会绕过。

Points that lie outside the receiver’s bounds are never reported as hits, even if they actually lie within one of the receiver’s subviews. This can occur if the current view’s clipsToBounds PRoperty is set to NO and the affected subview extends beyond the view’s bounds.

如果点击坐标不在视图范围内则绕过,但是如果子视图超出了子图bounds,事件落在在子视图上则执行该事件。

脚本宝典总结

以上是脚本宝典为你收集整理的IOS hitTest 详解全部内容,希望文章能够帮你解决IOS hitTest 详解所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。