//初始化一个UIImageView的对象
UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(100, 100, 200, 200)];
imageView.image = [UIImageimageNamed:@"filter_laozhaopian_a.png"];
imageView.userInteractionEnabled = YES;//打开用户交互
//初始化一个手势
UIGestureRecognizer *singleTap = [[UIGestureRecognizeralloc] initWithTarget:self action:@selector(singleTapAction:)];
//为图片添加手势
[imageView addGestureRecognizer:singleTap];
//显示
[self.view addSubview:imageView];
//点击事件
-(void)singleTapAction:(UIGestureRecognizer *)
{
//具体的实现
}
网友评论