【发布时间】:2014-03-14 05:36:14
【问题描述】:
我希望我的应用在按下按钮时播放动画,但是我希望动画的速度在中途减慢?目前,当我按下按钮时,我的应用会播放声音/动画,但是最后 50% 的帧太快了,我希望它放慢速度。
这是我的代码:
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController {
}
- (IBAction)Button {
AudioServicesPlaySystemSound(SoundID);
}
-(IBAction)startanimating{
animatedimage.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"frames_00.png"],
[UIImage imageNamed:@"frames_05.png"],
[UIImage imageNamed:@"frames_10.png"],
[UIImage imageNamed:@"frames_15.png"],
[UIImage imageNamed:@"frames_20.png"],
[UIImage imageNamed:@"frames_25.png"],
[UIImage imageNamed:@"frames_30.png"],
[UIImage imageNamed:@"frames_35.png"],
[UIImage imageNamed:@"frames_40.png"],
[UIImage imageNamed:@"frames_45.png"],
[UIImage imageNamed:@"frames_50.png"],
[UIImage imageNamed:@"frames_50.png"],
[UIImage imageNamed:@"frames_45.png"],
[UIImage imageNamed:@"frames_40.png"],
[UIImage imageNamed:@"frames_35.png"],
[UIImage imageNamed:@"frames_30.png"],
[UIImage imageNamed:@"frames_25.png"],
[UIImage imageNamed:@"frames_20.png"],
[UIImage imageNamed:@"frames_15.png"],
[UIImage imageNamed:@"frames_10.png"],
[UIImage imageNamed:@"frames_05.png"],
[UIImage imageNamed:@"frames_00.png"],nil];
[animatedimage setAnimationRepeatCount:1];
animatedimage.animationDuration = 0.7;
[animatedimage startAnimating];
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSURL *buttonURL = [NSURL fileURLWithPath: [[NSBundle mainBundle] pathForResource:@"AVTREV" ofType:@"mp3"]];
AudioServicesCreateSystemSoundID((__bridge CFURLRef)buttonURL, &SoundID);
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
第 50 帧是我希望它以更慢的速度播放的地方。任何帮助都会非常感谢您!
【问题讨论】:
-
animatedimage是UIImageView? -
把它分解成两个动画?一个速度为 100%,另一个速度为 50%
-
@user1846108 我该怎么做这到底是什么最好的方法?
标签: ios animation uiimageview