Skip to content

Instantly share code, notes, and snippets.

@MaximAlien
Created December 24, 2015 07:49
Show Gist options
  • Save MaximAlien/30153309f2f9147131ed to your computer and use it in GitHub Desktop.
Save MaximAlien/30153309f2f9147131ed to your computer and use it in GitHub Desktop.
[iOS] UITapGestureRecognizer example on UIView
- (void)viewDidLoad
{
[super viewDidLoad];
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
view.backgroundColor = [UIColor redColor];
[self.view addSubview:view];
UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handler:)];
[tapGestureRecognizer setNumberOfTapsRequired:1];
[tapGestureRecognizer setNumberOfTouchesRequired:1];
[view addGestureRecognizer:tapGestureRecognizer];
}
- (void)handler:(UITapGestureRecognizer*)sender
{
UIView *view = sender.view;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment