下面的範例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];
}
}