给UIImageView UILabel等没有自带点击事件的vi

2016-06-01  本文已影响72人  Mr_Dragonn
  UIImageView * imview = [[UIImageView alloc]init];
    imview.frame = CGRectMake(10, 10, 200, 200);
    imview.backgroundColor = [UIColor blueColor];
    [self.view addSubview:imview];
    imview.userInteractionEnabled = YES;
    [imview addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(haha)]];

-(void)haha{
    
        NSLog(@"xxxxx");
    
}
上一篇下一篇

猜你喜欢

热点阅读