rai*_*lin 74 iphone animation uiimageview ios4 ios
我搜索了很多SO的东西和Apple的参考资料,但仍然无法解决我的问题.
如何取消正在运行的动画?除了最后一个,我设法取消了...:/这是我的代码片段:
[UIImageView animateWithDuration:2.0
delay:0.1
options:UIViewAnimationOptionAllowUserInteraction
animations:^{
isAnimating = YES;
self.bigLetter.transform = CGAffineTransformScale(self.bigLetter.transform, 2.0, 2.0);
} completion:^(BOOL finished){
if(! finished) return;
[UIImageView animateWithDuration:2.0
delay:0.0
options:UIViewAnimationOptionAllowUserInteraction
animations:^{
self.bigLetter.transform = CGAffineTransformScale(self.bigLetter.transform, 0.5, 0.5);
} completion:^(BOOL finished){
if(! finished) return;
[UIImageView animateWithDuration:2.0
delay:0.0
options:UIViewAnimationOptionAllowUserInteraction
animations:^{
self.smallLetter.transform = CGAffineTransformScale(self.smallLetter.transform, 2.0, 2.0);
} completion:^(BOOL finished){
if(! finished) return;
[UIImageView animateWithDuration:2.0
delay:0.0
options:UIViewAnimationOptionAllowUserInteraction
animations:^{
self.smallLetter.transform = CGAffineTransformScale(self.smallLetter.transform, 0.5, 0.5);
}
completion:^(BOOL finished){
if (!finished) return;
//block letter buttons
[self.bigLetterButton setUserInteractionEnabled:YES];
[self.smallLetterButton setUserInteractionEnabled:YES];
//NSLog(@"vieDidLoad animations finished");
}];
}];
}];
}];
Run Code Online (Sandbox Code Playgroud)
不知怎的,smallLetter UIImageView无法正常工作,因为按下时(通过按钮)bigLetter正在取消动画...提前感谢:)
编辑: 我已经使用过这个解决方案,但仍然存在缩小smallLetter UIImageView的问题 - 根本没有取消... 解决方案
EDIT2:我在next/prev方法的开头添加了这个:
- (void)stopAnimation:(UIImageView*)source {
[UIView animateWithDuration:0.01
delay:0.0
options:(UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionAllowUserInteraction)
animations:^ {
source.transform = CGAffineTransformIdentity;
}
completion:NULL
];
}
Run Code Online (Sandbox Code Playgroud)
问题保持...:/不知道如何中断动画链中字母的最后一个动画
Nic*_*ood 141
您可以通过调用以下命令停止视图上的所有动画:
[view.layer removeAllAnimations];
Run Code Online (Sandbox Code Playgroud)
(您需要导入QuartzCore框架以在view.layer上调用方法).
如果你想要停止一个特定的动画,而不是所有的动画,你最好的办法是明确地使用CAAnimations而不是UIView动画助手方法,那么你将有更精细的控制,并可以通过名称明确地停止动画.
可以在此处找到Apple Core Animation文档:
Har*_*war 35
对于iOS 10,使用UIViewPropertyAnimator进行动画处理.它提供了启动,停止和暂停UIView动画的方法.
let animator = UIViewPropertyAnimator(duration: 2.0, curve: .easeOut){
self.view.alpha = 0.0
}
// Call this to start animation.
animator.startAnimation()
// Call this to stop animation.
animator.stopAnimation(true)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
48132 次 |
| 最近记录: |