Created
March 6, 2012 14:13
-
-
Save ahmattox/1986482 to your computer and use it in GitHub Desktop.
UIViewSubclass which lets touches pass through it but not it's subviews.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// TouchThroughView.h | |
// Created by Anthony Mattox on 3/5/12. | |
// | |
#import <UIKit/UIKit.h> | |
@interface TouchThroughView : UIView | |
@property (nonatomic) BOOL touchThrough; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// TouchThroughView.m | |
// Created by Anthony Mattox on 3/5/12. | |
// | |
#import "TouchThroughView.h" | |
@implementation TouchThroughView | |
@synthesize touchThrough; | |
- (BOOL) pointInside:(CGPoint) point withEvent:(UIEvent *) event { | |
if (touchThrough) { | |
if ([super pointInside:point withEvent:event]) { | |
for (UIView* subview in self.subviews) { | |
if (!subview.hidden && [subview pointInside:[self convertPoint:point toView:subview] withEvent:event]) { | |
return YES; | |
} | |
} | |
} | |
return NO; | |
} | |
return [super pointInside:point withEvent:event]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment