Tag: cabasicanimation

核心animation不能使用“alpha”值

在此代码之前,我的电影图片alpha设置为0, CABasicAnimation* fadein= [CABasicAnimation animationWithKeyPath:@"alpha"]; [fadein setToValue:[NSNumber numberWithFloat:1.0]]; [fadein setDuration:0.5]; [[moviepic layer]addAnimation:fadein forKey:@"alpha"]; 没有任何事情发生,如果我事先将alpha设置为0.5,alpha保持在0.5,而不是1。 我见过使用UIView beginAnimations:的代码UIView beginAnimations: around,但是我正在教授核心animation,所以我想知道为什么CABasicAnimation不能做这样简单的任务?

如何在Swift(HUGE_VALF)中永远重复animation?

根据文档,永远重复CABasicAnimation的方法是将其repeatCount设置为HUGE_VALF 。 但是在Swift中, HUGE_VALF会导致编译错误。 Swift似乎不了解标准库(或者这个常量所在的位置)。 现在我该怎么做?

在使用CABasicAnimation旋转CALayer之后,图层跳回到未旋转的位置

我正在试图创造一个下降的硬币。 硬币图像是CALayer上有2个CABasicAnimations – 一个倒下和一个旋转。 当倒下的animation结束时,它停留在那里。 虽然旋转animation应该是随机的,每次都会以不同的angular度结束,但是会popup原来的CALAyer图像。 我希望它保持在完成animation的angular度。 可能吗? 我该怎么做? 码: //Moving down animation: CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"transform.translation.y"]; anim.duration = 1; anim.autoreverses = NO; anim.removedOnCompletion = YES; anim.fromValue = [NSNumber numberWithInt: -80 – row_height * (8 – _col)]; anim.toValue = [NSNumber numberWithInt: 0]; //Rotation Animation: CABasicAnimation *rota = [CABasicAnimation animationWithKeyPath:@"transform.rotation"]; rota.duration = 4; rota.autoreverses = […]

animation完成后,CABasicAnimation重置为初始值

我正在旋转CALayer并在animation完成后试图将其停止在最终位置。 但animation完成后重置到其初始位置。 (xcode docs明确说animation不会更新属性的值。) 任何build议如何实现这一点。

有没有办法暂停CABasicAnimation?

我有一个iPhone的基本旋转animation。 有什么办法可以“暂停”animation,以保持视图的位置? 我想这样做的一个方法是导致animation“完成”,而不是调用“删除”,我怎么办呢? CABasicAnimation* rotationAnimation; rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2]; rotationAnimation.duration = 100; rotationAnimation.cumulative = YES; rotationAnimation.repeatCount = HUGE_VALF; rotationAnimation.removedOnCompletion = NO; rotationAnimation.fillMode = kCAFillModeForwards; [myView.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];