下面的范例App演示了以下控件的使用,经过滑块、步进控件和按钮来控制在图像视图中播放动画。ide
图像视图(UIImageView)动画
滑块(UISlider)spa
步进控件(UIStpper).net
范例App的运行效果,以下图所示:code
在图像视图中实现动画效果的部分代码:orm
- (IBAction)toggleAnimation:(id)sender {
get
if(bunnyView1.isAnimating){
[self.bunnyView1 stopAnimating];
[self.bunnyView2 stopAnimating];
[self.bunnyView3 stopAnimating];
[self.bunnyView4 stopAnimating];
[self.bunnyView5 stopAnimating];
[self.toggleButton setTitle:@"跳跃吧!" forState:UIControlStateNormal];
}
else{
[self.bunnyView1 startAnimating];
[self.bunnyView2 startAnimating];
[self.bunnyView3 startAnimating];
[self.bunnyView4 startAnimating];
[self.bunnyView5 startAnimating];
[self.toggleButton setTitle:@"停 止" forState:UIControlStateNormal];
}
}