for (int i = 0; i < 5; i++) {
//语音动画
UIImageView* recordAnimImage = [[UIImageView alloc]initWithFrame:CGRectMake(5, 5, 20, 20)];
recordAnimImage.image = [UIImage imageNamed:@"voice_dynamic3-1"];
UITapGestureRecognizer *labelTapGestureRecognizer = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(commentImageRecordClick:)];
recordAnimImage.tag = recordTag;
recordAnimImage.userInteractionEnabled = YES;
[recordAnimImage addGestureRecognizer:labelTapGestureRecognizer];
[self.contentView addSubview:recordAnimImage];
}
//点击事件
-(void)commentImageRecordClick:(UITapGestureRecognizer*)recognizer
{
//重点代码,判断点击的是哪一个imageView
UIImageView *recordAnimImage = (UIImageView *)recognizer.view;
recordAnimImage.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"voice_dynamic1-1"],
[UIImage imageNamed:@"voice_dynamic2-1"],
[UIImage imageNamed:@"voice_dynamic3-1"],nil];
recordAnimImage.animationDuration = 1;
recordAnimImage.userInteractionEnabled = NO;
recordAnimImage.animationRepeatCount = 3;
[recordAnimImage startAnimating];
}
iOS 如何处理多个UIImageView点击事件
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 本文章主要讲解怎么解决在Activity中,弹出Dialog后无法捕捉到Activity的Back点击事件。 通常...
- 项目源码下载 事件的产生与传递 事件是如何产生与传递的?当发生触摸事件后,系统会将该事件加入到一个由UIAppli...
- UIImageView* headerImVC = [[UIImageView alloc]initWithFra...
- 有的时候需要在图片上添加点击的事件又不想覆盖UIbutton来延时就可以这样了 创建两个 imageView [i...