4

Can some one please guide me how to create an Oscillation Animation on an ImageView.

I have a tag image and i want to animate it..

any code snippets of CABasicAnimation for it???

Shrey
  • 1,959
  • 2
  • 21
  • 44
  • If it's a "bouncing" effect you are looking for, check this question which is related to that: http://stackoverflow.com/questions/5161465/how-to-create-custom-easing-function-with-core-animation – Martin Wickman Mar 06 '11 at 13:44
  • If it's something like the shake animation on the springboard, maybe this article can help : http://www.cocoabyss.com/coreanimation/ios-springboard-shake-effect/ – scalbatty May 19 '11 at 11:39
  • 1
    no actually i want it like a pendulum.. :) – Shrey May 19 '11 at 13:28

1 Answers1

0

You could use:

+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay 
options:(UIViewAnimationOptions)options animations:(void (^)(void))animations 
completion:(void (^)(BOOL finished))completion

And use the Ease in and Ease out transitions to accelerate and decelerate toward the end.

Note: the blocks based animation is only valid in is 4.0 and later if you want earlier you need to use

+ (void)beginAnimations:(NSString *)animationID context:(void *)context

And its a simple matter of editing the frame of the view.

Codr
  • 68
  • 4