美文网首页
iOS UIImageView图片添加点击事件

iOS UIImageView图片添加点击事件

作者: Simon_Liang | 来源:发表于2018-11-15 11:36 被阅读0次

UIImage *img = [UIImage imageWithContentsOfFile:@"/Users/jinhui005/Desktop/style_img.png"];

UIImageView *imgView = [[UIImageView alloc] initWithImage:img];

UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(clickImage)];

[imgView addGestureRecognizer:tapGesture];

imgView.userInteractionEnabled = YES; 

相关文章

网友评论

      本文标题:iOS UIImageView图片添加点击事件

      本文链接:https://www.haomeiwen.com/subject/qwzefqtx.html