CSS pointer-events:none;allows click events to go through an element. I am curious if there is something similar that I can do in Objective-C on iOS for UIViews.
pointer-events:none;
UIView
Here's jsfiddle for example event pointers: none.
Can I somehow achieve the same behavior for UIView by overriding hitTest:withEvent: ? Or maybe there is another way to do this?
hitTest:withEvent:
Thanks for any help.
What you are looking for is usually called "Event Bubbling."
Apple : https://developer.apple.com/documentation/uikit/understanding_event_handling_responders_and_the_responder_chain
, , hitTest:withEvent:, , . .
:
#import "TouchTransparentView.h" @implementation TouchTransparentView -(id)hitTest:(CGPoint)point withEvent:(UIEvent *)event { id hitView = [super hitTest:point withEvent:event]; if (hitView == self) { return nil; } else { return hitView; } } @end
import UIKit class PassThroughView: UIView { override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { let hitView = super.hitTest(point, with: event) if hitView == self { return nil } else { return hitView } } }
...
-, pointer-events:none,
pointer-events:none
yourView.userInteractionEnabled = NO
.
Source: https://habr.com/ru/post/1529363/More articles:How to select multiple rows and sort them in one table using jquery sort - jqueryHow can we restart the service? - androidSKSpriteNode with the image will not be painted - iosManaging big data memory from oracle database - python-2.7ZXing.Net не может декодировать QR-код, захваченный камерой - c#Как легко построить диаграмму Вороного на сфере с CGAL? - c++Equivalent to a comma operator in MATLAB? - matlabSpherical space restricts triangle triangulation - c ++My private shortcode sets the content parameter to an empty string - phpHow can I check and use ... $ setPristine (); in the form of AngularJS? - angularjsAll Articles