Questions tagged [cabasicanimation]

"CABasicAnimation" is the most basic explicit animation in Core Animation. By simply specifying a "from" value, a "to" value and optionally other parameters like the duration you can have hardware accelerated animations in just a few lines of code.

CABasicAnimation is the most basic explicit animation in Core Animation (). By simply specifying a from value, a to value and optionally other parameters like the duration you can have hardware accelerated animations in just a few lines of code.

Animations are created with the key path that they should be animating like

CABasicAnimation *moveAnimation = 
↪   [CABasicAnimation animationWithKeyPath:@"position"];

After creating a new animation it is configured. Common configurations include setting the values to animate to and from, setting a duration and changing the timing function (how the animation is animated). Note that Core Graphics values have to be wrapped into NSValue objects when used.

// valueWithCGPoint: for iOS and valueWithPoint: for OS X.
[moveAnimation setFromValue:[NSValue valueWithCGPoint:myStartPoint]]; 
[moveAnimation setToValue:[NSValue valueWithCGPoint:myEndPoint]]; 
[moveAnimation setDuration:3.0]; // 3 seconds
[moveAnimation setTimingFunction:
↪   [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];

When the animation is configured it is applied by adding it to the layer that should animate. Note that the key parameter when adding the animation has nothing to do with the key path of the animation. It is only used to reference the animation after is has been added to the layer.

[myLayer addAnimation:moveAnimation 
               forKey:@"myMoveAnimation"];

Note that explicitly animating a property like this doesn't change the value of the actual property and after the animation finishes it will remove itself and the layer will jump back to the state it had before the animation. To also change the value of the property, explicitly change the value in the same before or after adding the animation to the layer.

One powerful feature even custom properties can be animated the same way (by specifying the key path).

Basic animations is available on both (since iOS 2.0) and (since OS X 10.5 "Leopard") and is part of the framework.

602 questions
0
votes
2 answers

CABasicAnimation doesn't trigger in viewWillAppear

I have a CABasicAnimation in the viewWillAppear method of "viewA". when I press a button in viewA to go to viewB and then go back to viewA the CABasicAnimation in the viewWillAppear (of viewA) works without problem. but, when I go from viewA to…
Ramin Afshar
  • 989
  • 2
  • 18
  • 34
0
votes
2 answers

Make UIImageView animate after another UIImageView has finished

I am trying to animate the dealing of cards. Currently I have two cards, the dealer card (dCard1) and the player card (pCard1). The player card should be dealt and as soon as it is dealt, the dealer card should then be dealt. What is currently…
user631063
0
votes
1 answer

Scrolling the array of images using the CABasicAnimation

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;  …
Perseus
  • 1,546
  • 4
  • 30
  • 55
-1
votes
1 answer

Animating 3 dots in swift iOS

I have a label and an image view. My goal is to have 3 dots animating infront of the label and to be at the foot of the label at the end as shown here I have been able to make this design with the dots moving fine on 12promax only however I can not…
deathAdder
  • 13
  • 8
-1
votes
1 answer

How to draw same bezier path multiple times after finished the previous one?

I am using bezier path, shape layer and CABasicAnimation to draw view animately. But it draw view only single time. How to draw same bezier path multiple times after finished the previous one ? This is the attached code for creating this type of…
Rahul Chopra
  • 187
  • 1
  • 13
-1
votes
1 answer

Unexpected behaviour in animation when i change the properties of the model layers

Referring to this post, i'm trying to adapt the animations to landscape mode. Basically what i want is to rotate all layers of -90° (90° clockwise) and the animations to run horizontally instead of vertically. The author didn't bother to explain the…
oneshot
  • 591
  • 1
  • 5
  • 27
-1
votes
1 answer

CABasicAnimation autoreverse twice as fast

I'm using this code to add pulsing circle with autoreverse: let scaleAnimation = CABasicAnimation(keyPath: "transform.scale") scaleAnimation.duration = 6 scaleAnimation.repeatCount = 200 scaleAnimation.autoreverses =…
klaudas
  • 427
  • 5
  • 13
-1
votes
1 answer

CGPath draw a loader

I juste watch this effect : alt text http://grab.by/5UBM I would like to reproduce it. Is it simply a CGPath animation? Have you got some indications so implement this beautiful loader view ? Thanks for your tips ;)
Pierre
  • 10,593
  • 5
  • 50
  • 80
-1
votes
1 answer

Assign toValue from an int

I'm doing an animation and want the toValue to get bigger every time i tap an image. My code will work (but doesn't now, of course), but how do you make a toValue an integer? I have this: int comboTapAnim = (comboTap / 10) + 1; then in the…
Yugaman
  • 59
  • 1
  • 12
-1
votes
1 answer

Why is my image not animating?

I have imported the QuartzCore framework I have imported the QuartzCore/CAAnimation.h file I have created a UIView Outlet Here's my code I have placed a breakpoint in my code and it does get called but the image does not move. What am I…
-1
votes
2 answers

basic animation a few images

I'm trying to animate the same images in a different position like this: for (int i = 0; i == 3; i++) { UIImageView *imageToAnimate = [[UIImageView alloc] initWithFrame: imageFrameTwo]; [imageToAnimate setImage: [UIImage…
Pavel
  • 167
  • 2
  • 11
-1
votes
1 answer

How to create animations like the ones in Photo Booth?

I am a beginner in the world of Objective-C, and for my first iOS application, I thought I'd create one similar to Photo Booth. Now, I've done some tinkering with CABasicAnimation, and I was wondering whether there was one which makes the…
user2828375
  • 31
  • 1
  • 2
-1
votes
1 answer

How to achieve animation effects like(word puzzle game) in iphone application?

i need to achieve an animation effect like (the Effects in "Pic Something","Pic Reveal" and so on) in my app. What i am saying is i need to implement this tasks Task1: when the user touches one Letter, then it change its frame(current position) to…
-1
votes
1 answer

Why does CABasicAnimation show two points moving?

I am trying to show a simple point moving. I set up a layer, set the bounds, position and color, and then use CAAnimation to show it moving CALayer *l = [CALayer layer]; l.bounds = CGRectMake(0,0,20,20); l.position = CGPointMake(x,y); …
-2
votes
1 answer

CAShapeLayer jittery animation in iOS

I am trying to animate loading animation along the path of rounded rect,using following code. (I need to animate border of square as loader ,partial border.) It does not happen to be smooth ,as soon as it reaches the end of path it jumps to the…
Deep
  • 51
  • 5
1 2 3
40
41