Skip to content

Instantly share code, notes, and snippets.

@guange2015
Created September 16, 2012 05:47
Show Gist options
  • Select an option

  • Save guange2015/3731169 to your computer and use it in GitHub Desktop.

Select an option

Save guange2015/3731169 to your computer and use it in GitHub Desktop.
uitextfield transparent view
@interface UIClickView : UIView
@property (nonatomic,assign)UITextField* edit;
@end
@implementation UIClickView
- (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
CGPoint p = [self convertPoint:point toView:self.edit];
if (p.x>0 && p.y>0) {
return nil;
}
return [super hitTest:point withEvent:event];
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [touches anyObject];
CGPoint p = [touch locationInView:self.edit];
if (p.x <0 || p.y<0) {
[self.edit resignFirstResponder];
}
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment