cabasicanimation

After rotating a CALayer using CABasicAnimation the layer jumps back to it's unrotated position

北城以北 提交于 2019-12-17 22:10:50
问题 I am trying to create a falling coin. The coin image is a CALayer with 2 CABasicAnimations on it - a falling down and a rotation one. When the falling down animation gets to its end, it stays there. The rotation animation though, which is supposed to be random and end up in a different angle every time, just pops back to the original CALAyer image. I want it to stay in the angle it finished the animation on. Is it possible? How do I do it? Code: //Moving down animation: CABasicAnimation *anim

CABasicAnimation resets to initial value after animation completes

人走茶凉 提交于 2019-12-17 17:20:24
问题 I am rotating a CALayer and trying to stop it at its final position after animation is completed. But after animation completes it resets to its initial position. (xcode docs explicitly say that the animation will not update the value of the property.) any suggestions how to achieve this. 回答1: Here's the answer, it's a combination of my answer and Krishnan's. cabasicanimation.fillMode = kCAFillModeForwards; cabasicanimation.removedOnCompletion = NO; The default value is kCAFillModeRemoved .

Rotate and translate UIImageView off and on screen

风流意气都作罢 提交于 2019-12-13 20:04:56
问题 How can I rotate and translate a UIImageView off one side of the screen, then its coming back from the other side.. Lets say I have a Wheel that I want to rotate and translate from the middle then off the screen to the left, then its "coming back" from the right side and back the middle.. I used following code to rotate and translate it OFF the screen; CABasicAnimation* rotationAnimation; rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; rotationAnimation

How to properly animate sequentially using CAAnimation

情到浓时终转凉″ 提交于 2019-12-13 15:53:37
问题 I'm simply closing doors, delaying 2 sec/calling a method then opening them back. One comes from the left side and the other from the right side. I first used UIView animation block but then realized whenever user leaves the app during animation, its completion block would never get called. I could not find anyone complaining about such behavior when interruption happens during animation thus could not solve the problem and now I'm hoping CAAnimation's animationDidStop or CATransaction's

Animating CALayer background color and update model value

强颜欢笑 提交于 2019-12-12 16:11:22
问题 I want to animate a backgroundColor change for a sublayer in my UIView (on tintColorDidChange ). I need to animate from the layer's current background colour to the new tint colour several times (different tint colours each time), so the model value for backgroundColor needs to be updated (I can't use removedOnCompletion = false on the animation). Using CABasicAnimation I have the colour change animation working fine if I don't update the model value (but of course the colour resets after the

CABasicAnimation is not working when the method is called from the viewDidLoad

你说的曾经没有我的故事 提交于 2019-12-12 05:13:17
问题 I have an imageView added to a view that's presented as a modalViewController, with style horizontal flip. I have added the following code for animating the imageView. - (void)animateTheImageview:(UIImageView*) imageViewToAnimate{ CABasicAnimation *fadeAnimation; fadeAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"]; fadeAnimation.duration = 1.5; fadeAnimation.repeatCount = INFINITY; fadeAnimation.autoreverses = NO; fadeAnimation.fromValue = [NSNumber numberWithFloat:1.0];

CAAnimation: Don't reset after animation

*爱你&永不变心* 提交于 2019-12-12 03:04:06
问题 I have this code to move a view. CABasicAnimation *theAnimation; theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.translation.x"]; theAnimation.duration=1; theAnimation.repeatCount=1; theAnimation.autoreverses=NO; theAnimation.fromValue=[NSNumber numberWithFloat:0]; theAnimation.toValue=[NSNumber numberWithFloat:-60]; [view.layer addAnimation:theAnimation forKey:@"animateLayer"]; The problem is: The actual coordinates of the view get reseted after the animation has finished. Is

CABasicAnimation - Animating between two angles

戏子无情 提交于 2019-12-12 00:45:08
问题 I'm attempting to create an animated CALayer that uses a CABasicAnimation in order to animate an object that rotates at discrete intervals between two angles. Note the word discrete: I'm not trying to create a continuous animation between two points, but rather I want to calculate fixed increments between each angle in order to create a discrete movement feel. Here's a diagram: I've looked into setting the byValue attribute of the CABasicAnimation , but I can't seem to get it to work since

Scrolling the array of images using the CABasicAnimation

岁酱吖の 提交于 2019-12-11 20:11:13
问题 I have to scroll the images one by one. THe following are the code which i am using _imageView is UIImageView and imagesArray is the NSArray with array of objects. _imageView.animationImages=imagesArray; _imageView.animationDuration=10; [_imageView startAnimating]; CABasicAnimation *scrollText; scrollText=[CABasicAnimation animationWithKeyPath:@"position.x"]; scrollText.duration = 10.0; scrollText.speed= 3; scrollText.repeatCount = 0; scrollText.autoreverses = NO; scrollText.fromValue =

Is CABasicAnimation's toValue relative to initial position?

冷暖自知 提交于 2019-12-11 13:31:18
问题 I have a CALayer that I'm explicitly animating to a new position. My toValue property seems only relative to the layer's initial position. CABasicAnimation *move = [CABasicAnimation animationWithKeyPath:@"position"]; move.fromValue = [NSValue valueWithCGPoint:CGPointMake(blueDot.position.x, blueDot.position.y)]; move.toValue = [NSValue valueWithCGPoint:CGPointMake(self.view.center.x, self.view.center.y)]; move.duration = 1.0; [blueDot addAnimation:move forKey:@"myMoveAnimation"]; blueDot