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");
}
复制代码
给UIImageView UILabel等没有自带点击事件的view添加点击事件
程序员文章站
2024-01-15 19:25:10
...
转载于:https://juejin.im/post/5a31007c6fb9a045263b95cc
上一篇: 应该如何当好一名站长
下一篇: ObjectiveC 图片压缩