给UIImageView UILabel等没有自带点击事件的view添加点击事件
程序员文章站
2024-01-15 19:14:10
...
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");
}
上一篇: TextView控件属性列表
下一篇: CSS核心属性-列表属性