Need help in animating a Wheel on iphone - iphone

I am doing an application in iphone that need to spin the Dart Wheel when I drag on it. The view will have a dart wheel image and when we drag the wheel it spins and slowly it stops.
Can any one help me in doing this animation.

You can use CoreAnimation for the rotation animation:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView setAnimationDuration:1.0f];
[view.layer setTransform:CGAffineTransformMakeRotation(M_PI)];
[UIView commitAnimations];
You will have to tweak the animation for your needs.

Related

iPhone UIView animation

Grettings to you...
i want to paginate when the user swipe on the left or right side of the uiview
i am able to detect the swipes using UISwipeGestureRecognizer.
now what i am trying to do is when the user is swiping i want to give slide animation.
currently i have the below code
[UIView beginAnimations:nil context:nil];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft, forView:[self cardView] cache:YES];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.5];
this gives me the flip effect when i swipe on the view.
Please provide me some example or links to try the slide effect when swipe on the view.
Many Thanks!
You're going to want to use a UIScrollView, not a straight UIView. This has support for swipes and paging. Here's a nice tutorial to get you started. Good luck!

Animation on view

i have 2 toolbar one at top and another at bottom
in between of these two i have a webview and i apply a turn page animation on it.
But my problem is that on Animation both tool bar are also move with them how can i stop toolbar animation.only webview is animated
Thanks
[UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:1];//0.3]; [UIView setAnimationDelegate:self]; [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:NO];
From your description, I think you are applying the animation on your main view (which contains the toolbars and the web view) and not on the web view only.
Post some code that might make things clearer.
EDIT:
Like i said you have applied the animation to your main view 'self.view' instead of your web view and hence the entire view is being animated..
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:NO];
instead try applying it to your web view:
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.myWebView cache:NO];

How can we turn views like turning a page in an iphone application?

Is it possible to turn a view slowly like turning a page? When i swipe from right to left, the current view will turn and the next view will be shown. And from left to right, the previous view will come slowly as we move the finger.
How can I do it? Any ideas??
You should add and remove subviews from your view by detecting the touch movements, using the animation transtion styles:
UIViewAnimationTransitionCurlUp //for removing views (vice-versa)
UIViewAnimationTransitionCurlDown // for adding views (vice-versa)
like:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:NO];
[self.view addSubview:nextView];
[UIView commitAnimations];
You should customize above according to ur needs.
Hope this helps.
Thanks,
Madhup

Animating UIView problem (matching the expanding animation to the shrinking animation)

I'm trying to animate a UIView so that it can grow larger when tapping a button and shrinks down to its original size by tapping the button again.
I do this by adjusting frame to its new size and origin and running the code below.
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
self.theView.frame = frame;
[UIView commitAnimations];
When animating to a bigger size the animation is how it should be. But when animating to its original size (smaller) the view is re-sized instantly and then animated to its designated location.
What I need is that the resizing to the smaller frame is animated as well.
I've tried adjusting the autoresizingMask as well, but that didn't change anything.
Hope someone can help.
thanks.
Michiel, Raj,
I made a youtube tutorial showing how to make views expand and shrink like in the facebook iPhone app.
Hope it can be of some help: How to make expanding/shrinking views on iPhone SDK
Adam
Try this
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.5];
[UIView setAnimationRepeatAutoreverses:YES];
self.theView.frame = frame;
[UIView commitAnimations];
In response to comment;
If you want to control animation reverse, have a flag like BOOL isbig and set it in app launch to NO, then toggle it in every button tap, then check it if it is YES or NO, and according to the result call a method. If NO, call your code, if not call the code again but this time set the frame to the original size.
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
self.theView.frame = originalFrame;
[UIView commitAnimations];
I could solve the problem by suggestion found in other thread, it has its own limitations though. I have posted the code in the same thread where the solution was suggested:
UIView scaling during animation
I worked around this problem when releasing my app by just removing the animation.
It kept bugging me in the back of my mind, so just this week I thought that maybe by using the center property and the size instead of the origin it would make a difference.
So I decided to test this out. Guess what. The problem doesn't occur when using sdk 4.x
Thanks all for trying to help me out.

Animate leafing through?

Is there any way to animate leafing through views to look like a real book leafing through?
There is always the option of using CoreAnimation to animate any view. For this purpose, it could become quite complex though.
There is a native animation for UIView that peels it up from the corner like a page. This kind of animation is more akin to leafing through a notepad than a book but it may just serve the purpose your looking for. If you wanted to do this it would look something like this:
[UIView setAnimationDuration:duration];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:view cache:NO];
[UIView commitAnimations];
The duration of the animation can be set to whatever you like.