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];
}
网友评论