tags:

views:

45

answers:

2

Hello veteran xcoders,

I just wanna know if there exists simple drawer (move up and down certain pixels)like animation for generic iPhone button as animated action or not?

How one can approach to implement that.

Can someone guide me.Thanks for your effort in advance.

A: 

The animation system in cocoa-touch is very powerful. You only need to create an animation block where you set the values you want animated. For example, taking your button and moving it would be as simple as assigning the new position to it and triggering the animation:

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.3];

//modify any animatable property (scale, position, tranparency, etc)
yourButton.center = CGPointMake(newX, newY);

[UIView commitAnimations];

Now this is the simplest way to animate, but there is a lot that you can control. You can change the animation curb, ask the animation to call you back when it's finished, etc.

If you have access to the 2010 wwdc conference presentations (every registered developper can view them), there is one presentation dedicated to animation on the iphone: look for Session 123. Time well invested.

David
Thanks man!Thanks for your time on sorting this out.
daniel
A: 

Try this:

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
square.transform = CGAffineTransformMakeTranslation(0, -100);
[UIView commitAnimations];

This code will move the image "square" 100 pixels up (negative is up and positive is down)

You also can scale, rotate, change transparency, etc.

DailyDoggy
Thanks for your idea.I highly appreciate your input.
daniel