I am very new to animation in iphone . To start with i wanted to implement spinning of earth or globe . how can i do implement it in iphone
thanks in advance
For 2D animation you would need a number of frames (ideally 360) and then step through the frames in an UIImageView. You can set the animationImages property using this example
you can use this...this is not spinning but moving image from one location to another
CGRect tempFrame=theView.frame;
tempFrame.origin.x=tempFrame.origin.x+50;
[UIView beginAnimations:#"" context:nil];
[UIView setAnimationDuration:2];
theView.frame=tempFrame;
[UIView commitAnimations];
Related
i am developing a app and it has this button call menu. When i click that button it addsubview the menu view to the main view. But I need to add it like comming out from the button. Like speech bubble.
Here is a sample image i take from some iphone app and they did awesome job to animate the view, like a bubble come out from button.
this is the app i am talking about which is having the animation i mentioning.
Download Waze App from here
if you are using iphone, download it and take a look at it. Then you will get proper idea about how that animation happening. Its a free app btw.
I search through the net to find a solution for this but i couldn't find any thing helpful. There are some ideas to do it like scalling the subview, using following code. I tried it with some view animations, it has some progress but not good enough.
CGAffineTransform transform = CGAffineTransformMakeScale(1.2, 1.2);
But I am pretty sure that is not the correct way to do it. There should be a proper way to do it.
Can any one give me help me to over come this issue.
Thanks in Advance
In my project I have used the following code for animating from left to right. Changing the value for CGAffineTransform (x and y position) will provide variations. Hope this would help you!
[self.view addSubview:subView];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.0];
CGAffineTransform t2 = CGAffineTransformMakeTranslation(SubView_Width, 0);
subView.transform = t2;
subView.alpha = 1;
[UIView commitAnimations];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationDelegate:self];
subView.alpha = 1;
subView.transform = CGAffineTransformIdentity;
[UIView commitAnimations];
you need this - popover for iPhone, http://mobiledevelopertips.com/open-source/ios-open-source-popover-api-for-iphone-wepopover.html
I just wanted to create animation for clock to appear as in this video.
I have no idea how create it. Any solution?
When you click on bulb icon in slider below, the clock will appear and on clicking again clock will disappear.
If you want your app to be iOS < 4 compatible, use this:
[UIView beginAnimations:#"animation" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveLinear]; //Different Animation Curves available, check docs.
[UIView setAnimationDuration:1.0]; //In seconds
//Here do your stuff
int newPosY = myImage.frame.origin.y - 10;
[myImage setFrame:CGRectMake(self.frame.origin.x, newPosY, myImage.frame.size.width, myImage.frame.size.height)];
[UIView commitAnimations];
This snippet moves your image 10 pixels up. You can customize the animation making changes to the image frame before calling commitAnimations
Also check the UIView Reference to extended info.
I noticed in the Jamie Oliver app, when you click one of the buttons, it goes from one size to another in a smooth transition. Does anyone know how this is done? I tried using some of the UIView animations, but none of them satisfies my needs.
UIAnimations alone can not give you that effect.. You need to couple them with transformations to achieve the effect that you are talking about. Try it in the following way. You will get what you need...
[UIView beginAnimations:#"Zoomin" context:nil];
[UIView setAnimationDuration:0.25];
starImage.transform=CGAffineTransformMakeScale(2.5, 2.5);
[UIView commitAnimations];
[UIView beginAnimations:#"Zoomout" context:nil];
[UIView setAnimationDuration:0.25];
starImage.transform=CGAffineTransformMakeScale(1, 1);
[UIView commitAnimations];
I believe animation blocks are the preferred method for animating views now.
I have a custom view that has to track the user's location. I put the following code in touchesBegan, as well as in touchesMoved:
[UIView animateWithDuration:0.2 delay:0.0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
cursorView.center = locationOfTouch;
} completion:^(BOOL finished){}];
It seems fairly straightforward to me. I'd expect the view to always animate to the user's current location, even if that location is changed and the view is still animating (because of the beginFromCurrentState option).
Yet, each animation finishes completely. They don't 'transition' to the new animation, no they finish first, then they start the new animation.
I tried adding this line in touchesMoved:
[cursorView.layer removeAllAnimations];
Doesn't do anything. No animation is cancelled. Any ideas?
with [cursorView.layer removeAllAnimations]; you access the layer of the view but you have set the animation not to the layer but the view directly.
Try:
[UIView beginAnimations:nil context:NULL]
[UIView setAnimationDuration:0.2];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
cursorView.center = locationOfTouch;
[UIView commitAnimations];
and leave out the removeAllAnimations and it should transition from current state.
Looks like this is a derivative of another question you asked that I just answered, but the same idea applies.
You don't need to use blocks to do this. Just wrap your setCenter in a UIView animation. Like this:
[UIView beginAnimations:nil context:NULL]
[UIView setAnimationDuration:0.2f];
cursorView.center = locationOfTouch;
[UIView commitAnimations];
Keep in mind that 0.2 seconds is pretty fast. It may appear to be "jumping" to the position. To confirm, set the duration to something like 2.0 seconds and see if it's animating.
Best regards.
Technically, the view should automatically animate with a default time of 0.25 seconds. That is what the manuals say, however, I'm currently on here because the manuals don't seem to be very accurate regarding animation.
Also, the beginAnimations call is being phased out, you might want to use a CATransaction instead
I have a card (a flashcard you could say)
What I can do:
On fingersweeping over the flashcard the card gets turned. It's happening by detecting
touchesBegan and touchesMoved and then I do stuff like
[UIView beginAnimations:#"View Flip" context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
if (left) {
[UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft forView:self.flashCardView cache:YES];
}else{
[UIView setAnimationTransition: UIViewAnimationTransitionFlipFromRight forView:self.flashCardView cache:YES];
}
What I can't do (but want to):
I want to somehow drag the flip.
Imagine this, you have a flashcard and you think you know the answer, you start flipping the card around because you want to see if you are correct, but then... no stop... you hesitate, turn back the card to the way it was, rethink, get the real answer and then finally flip to see that you were right to hesitate.
Now I only have: once you start flipping, you can't stop it.
So do you have any hints on how to do this ? something to read ? I'm still at the beginning of understanding cocoa and iPhone development
EDIT I'm more experienced now, but I still haven't done such custom animations, maybe someone can give me a lift ?
You cannot achieve what you're trying to do with the preset UIView animations because the animation is one-time and cannot be intercepted. You can use OpenGL for true 3D transformations (what you need is rotation about an axis), or for a speedier implementation try CALayer transforms as drawnonward suggested.
Here is an example of the interactive 3D page flip implemented in OpenGL. It uses private APIs, but it might help you understand how to respond to user input and apply transforms appropriately.