首先请问一个可能是菜鸟的问题!我对目标C完全陌生!
我想对图像进行动画处理,动画结束时应显示动画“ dymchart20.png”的最后一个图像。我怎样才能做到这一点?
这是我的动画代码:
aniChartView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"dymchart01.png"],
[UIImage imageNamed:@"dymchart02.png"],
[UIImage imageNamed:@"dymchart03.png"],
[UIImage imageNamed:@"dymchart04.png"],
[UIImage imageNamed:@"dymchart05.png"],
[UIImage imageNamed:@"dymchart06.png"],
[UIImage imageNamed:@"dymchart07.png"],
[UIImage imageNamed:@"dymchart08.png"],
[UIImage imageNamed:@"dymchart09.png"],
[UIImage imageNamed:@"dymchart10.png"],
[UIImage imageNamed:@"dymchart11.png"],
[UIImage imageNamed:@"dymchart12.png"],
[UIImage imageNamed:@"dymchart13.png"],
[UIImage imageNamed:@"dymchart14.png"],
[UIImage imageNamed:@"dymchart15.png"],
[UIImage imageNamed:@"dymchart16.png"],
[UIImage imageNamed:@"dymchart17.png"],
[UIImage imageNamed:@"dymchart18.png"],
[UIImage imageNamed:@"dymchart19.png"],
[UIImage imageNamed:@"dymchart20.png"],nil];
// all frames will execute in 3 seconds
aniChartView.animationDuration = 0.8;
// repeat the annimation forever
aniChartView.animationRepeatCount = 1;
// start animating
[aniChartView startAnimating];
谢谢您的帮助!!!
您可以使用NSTimer并将其声明为aniChartView作为类的属性,如下所示:
@interface ViewController ()
@property (nonatomic, strong) UIImageView *aniChartView;
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)beginAnimation {
self.aniChartView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"dymchart01.png"],
[UIImage imageNamed:@"dymchart02.png"],
[UIImage imageNamed:@"dymchart03.png"],
[UIImage imageNamed:@"dymchart04.png"],
[UIImage imageNamed:@"dymchart05.png"],
[UIImage imageNamed:@"dymchart06.png"],
[UIImage imageNamed:@"dymchart07.png"],
[UIImage imageNamed:@"dymchart08.png"],
[UIImage imageNamed:@"dymchart09.png"],
[UIImage imageNamed:@"dymchart10.png"],
[UIImage imageNamed:@"dymchart11.png"],
[UIImage imageNamed:@"dymchart12.png"],
[UIImage imageNamed:@"dymchart13.png"],
[UIImage imageNamed:@"dymchart14.png"],
[UIImage imageNamed:@"dymchart15.png"],
[UIImage imageNamed:@"dymchart16.png"],
[UIImage imageNamed:@"dymchart17.png"],
[UIImage imageNamed:@"dymchart18.png"],
[UIImage imageNamed:@"dymchart19.png"],
[UIImage imageNamed:@"dymchart20.png"],nil];
// all frames will execute in 3 seconds
self.aniChartView.animationDuration = 0.8;
// repeat the annimation forever
self.aniChartView.animationRepeatCount = 1;
// start animating
[self.aniChartView startAnimating];
[NSTimer scheduledTimerWithTimeInterval:0.8 target:self selector:@selector(staticImage) userInfo:nil repeats:NO];
}
-(void)staticImage {
[self.aniChartView stopAnimating];
[self.aniChartView setImage:[UIImage imageNamed:@"dymchart20.png"]];
}
@end
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句