- (IBAction)onButtonClickHandler:(id)sender {
UIImageView *heartImageView = [[UIImageViewalloc]initWithFrame:CGRectMake(100.0, 100.0, 50.0, 50.0)];
[self.view addSubview:heartImageView];
NSMutableArray *images = [[NSMutableArrayalloc]initWithCapacity:7];
for (int i=1; i<=7; i++) {
[images addObject:[UIImageimageNamed:[NSStringstringWithFormat:@"xxx%d.png",i]]];
}
heartImageView.animationImages = images;
heartImageView.animationDuration = 0.4 ;
heartImageView.animationRepeatCount = 1;
[heartImageView startAnimating];
[NSTimer scheduledTimerWithTimeInterval:heartImageView.animationDuration
target:self
selector:@selector(onFrameAnimationFinished:)
userInfo:heartImageView
repeats:NO];
}
- (void)onFrameAnimationFinished:(NSTimer *)timer{
UIImageView * imageView = (UIImageView *)[timeruserInfo];
[imageView removeFromSuperview];
}