I have a UIWebView. Using something like this:
http://blog.evandavey.com/2009/02/how-to-make-uiwebview-transparent.html
.. I have made the UIWebView transparent. I now need to be able to pass though touches on the webview to the view below, but only on a rectangular portion of the web view.
So, imagine the webview is a square, and it has a square area in the centre which must pass-thru touches to the view below.
Is there a way to do this?
This is a more specific form of
hitTestmanipulation.First, create a subclass of
UIView. I called mineViewWithHole.In its header, define a property for a
UIViewthat will be the hole through the outer view. Make this anIBOutlet.Then override
hitTest. If the point is returns a hit within the hole, return that. Otherwise return what it usually would.In Interface Builder, or programmatically, place a
ViewWithHole. Put aUIViewand aUIWebViewwithin it, in that order. Make theUIViewtheholeViewof theViewWithHole.The
holeViewcan itself be interactive, or you can put any number of interactive views within it. Here, I put a few standard views in there to make sure they work. Any taps on within the hole will be sent to it and its subviews, not theUIWebViewon top. Any taps outside theholeViewwill be received by theUIWebViewas usual.You can have any number and type of views displayed in front of the hole; all that matters is that the
holeViewis properly connected.