iphone - How can I click a button behind a transparent UIView? -


Assume that we have a view controller with a sub view. The subview takes 100 px margins on all sides of the center of the screen. After that we add a bunch of very little stuff to click inside that subview. We are only using the sub-view to take advantage of the new frame (actually in the 100x100 subclasses x = 0, y = 0)

Again, imagine that we have a There is something behind Subway, like the menu. I want the user to be able to select "small things" in the subview, but if there is nothing there, then I want to touch it (the background is completely clear) at the back button

How can I do this? It seems to touch the baggo goes, but the buttons do not work.

Create a custom view for your container and override the point End: Within a qualified child's view , Such as:

  @interface PassthroughView: UIView @end @implementation PassthroughView - (BOOL) pointInside: (CGPoint) Doc with point: (UIEvent *) event {for (UIView * self.subviews See) {if !! View.hidden & amp; Amp; View.alpha & gt; 0 & amp; Amp; Amp; And view.userInteractionEnabled & amp; Amp; [See inside point: [Self convert point: see from the point of view: see] Event: Event]) Yes return; } no return; } @ And  

Using this view as a container, it will be allowed to touch any child, but the scene itself will be transparent for the events.

EDIT: Here is Swift version

  class close tooth view: UIView {Override function point-end (point: CP point, event event: UIEvent?) - & gt; Bowl {For SubViews in SubViews {if! Subview.hidden & amp; Amp; Subview.alpha & gt; 0 and amp; Amp; Subview.Useer Interaction Enabled & amp; Amp; Swift 3:  
   

Class close tutru scene: UIView {Override Function Point (inside point: CGPoint, with Event: UIEvent ?) - & gt; Bowl {For SubViews in SubViews {if! Subview.isHidden & amp; Amp; Subview.alpha & gt; 0 and amp; Amp; Subview Eusier Interaction Enabled & amp; Amp; Subview.point (inside: with (point: to: subview): with event) {return true}} return false}}


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -