我有一个 viewController 正在播放声音AVAudioPlayer
,计时器正在运行 2 分钟,NSTimer
并且正在播放一系列动画
[UIView animateWithDuration:2.0
delay:0.0
options:UIViewAnimationOptionCurveLinear
animations:^{
//Rolling the Man's tongue out
_cooling2ManImage.alpha = 1.0;
_cooling3ManImage.alpha = 0.0;
}
completion:^(BOOL boolValue){
[UIView animateWithDuration:2.0
delay:0.0
options:UIViewAnimationOptionCurveLinear
animations:^{
//showing the Arrow image and translating the arrow to the mouth
_cooling1ArrowImage.alpha = 1.0;
_cooling1ArrowImage.transform = CGAffineTransformMakeTranslation(0,-110);
}
completion:^(BOOL boolValue){
[UIView animateWithDuration:1.5
delay:0.0
options:UIViewAnimationOptionCurveLinear
animations:^{
//Hiding the arrow
_cooling1ArrowImage.alpha = 0.0;
}
completion:^(BOOL boolValue){
_cooling1ArrowImage.transform = CGAffineTransformMakeTranslation(0,0);
[UIView animateWithDuration:2.0
delay:0.0
options:UIViewAnimationOptionCurveLinear
animations:^{
//Roll the tongue back in
_cooling2ManImage.alpha = 0.0;
_cooling3ManImage.alpha = 1.0;
}
completion:^(BOOL boolValue){
//Show the arrow and translate it
[UIView animateWithDuration:2.0
delay:0.0
options:UIViewAnimationOptionCurveLinear
animations:^{
_cooling3ArrowImage.alpha = 1.0;
CGAffineTransform scale;
CGAffineTransform translate;
scale = CGAffineTransformMakeScale(2.5, 2.5);
translate = CGAffineTransformMakeTranslation(0, 40);
_cooling3ArrowImage.transform = CGAffineTransformConcat(scale, translate);
_cooling3ArrowImage.alpha = 0.0;
}
completion:^(BOOL boolValue){
[UIView animateWithDuration:2.0
delay:0.0
options:UIViewAnimationOptionCurveLinear
animations:^{
_cooling2ManImage.alpha = 0.0;
_cooling3ManImage.alpha = 1.0;
_cooling1ArrowImage.alpha = 0.0;
_cooling3ArrowImage.alpha = 0.0;
_cooling3ArrowImage.transform = CGAffineTransformMakeTranslation(0,0);
_cooling3ArrowImage.transform = CGAffineTransformMakeScale(1,1);
if (count <= 6 ) {
[self startAnimation1];
count += 1;
NSLog(@"%i",count);
}
}
completion:nil];
}];
}];
}];
}];
}];
我必须实现暂停和恢复功能,以便当用户点击“暂停”按钮时,音频、动画和计时器暂停,当用户点击恢复按钮时,它会从暂停的位置恢复。任何人都可以让我知道我怎样才能做到这一点?