Created
          December 24, 2015 07:49 
        
      - 
      
 - 
        
Save MaximAlien/30153309f2f9147131ed to your computer and use it in GitHub Desktop.  
    [iOS] UITapGestureRecognizer example on UIView
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | - (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