I'm going to make a quiz game where user will have to pick correct answer from 4 options.Those options will be image format.I want those rectangular images will appear on screen on by one by Pop Up animation.
Can you please tell me how can i add a popup animation on iPhone App?
NB: The pop up animation should be like Pop Up transition in Keynote.I mean after Pop Up it will vibrate a little bit back and forth.
Check this SO link
You can tinker with the values depending on how you want your animation.
//Set default frame for all 4 images.
[UIView animateWithDuration:0.5 animations:^{
//set frame for first image
} completion:^(BOOL finished) {
//this block will call after first animation is done.so after that animate 2nd image . do same for all 4 image.
}];
maybe this will help you.
Related
I have several images that I want to move sequentially, across the screen, each with a specific delay. I have animated the first image like this:
[UIView animateWithDuration:0.5f
animations:^{
image1.center = CGPointMake(image1.center.x + 10.0f, image1.center.y);
}
completion:nil];
Now I want to move image2 behind image 1. Do I have to add a delay for image2? I mean, I want image2 to follow image1 in moving across the screen. How do I do this?
P.S: The above code moves image1 from left to right, across the screen.
Put the animation method (
animateWithDuration:delay:options:animations:completion:) in the completion block of the first animation. Add whatever delay you want (the delay will be between the end of the first animation and the start of the second).
We have this animation for some bubble effect on a button , but it prevent him from being clickable. if we disable this animation he works.
Can we fix it to let it work with the animation ?
CGRect initi=[[initialPositions objectAtIndex:b.tag] CGRectValue];
int r1=arc4random()%4;
int r2=arc4random()%4;
initi.origin.x+=r1;
initi.origin.y+=r2;
[UIView animateWithDuration:0.8 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^
{
b.frame=initi;
}
completion:^(BOOL completed){ }];
As far as I know, the button is not actually disabled or unclickable during the animation. When the animation starts the button's touch area is immediately moved to the position where the button will be when the animation ends. This makes it feel like the button were unclickable during the animation.
From touch logic's point of view, the button is just moved from A to B and animation between A and B is just eye candy. This explains why touching doesn't work between the points.
The only working solution to this is to roll your own animation routine. If you want to take this route, this post called The Holy Grail of iOS Animation Intervals? by Ben Bojko should point you to the right direction.
As Markus says in his answer (voted) the button actually moves to it's end position at the beginning of the animation, and will accept clicks there as soon as the animation starts. The animation actually takes place in view hierarchy's "presentation layer".
You can use Markus' suggestion of doing your own animation, but that is processor-intensive and not as smooth as layer-based animation (which is how UIView animation works under the covers.)
If you want to use UIView animation and have your button respond to clicks while the animation is in-flight then you need to make the superview that bounds the entire animation clickable, and implement hit testing on the button's presentation layer to figure out if the tap hits the button or not. (the superview takes the tap, then checks it's coordinates to see if it is inside the buttons' presentation layer using the hitTest: method.)
I have a project on github called iOS CAAnimationGroup demo (link) that shows how to do this, both for CAAnimation based animation and UIView-based animation.
Anybody have any idea how this is done?
http://youtu.be/r_cII4_aq_A
In general, the idea is awesome, but I would like to know how to do each specific thing. In the video, the pages are being swiped too fast so you can't see, but as you transition from one page to the next, each pixel smoothly transitions to it's new color. Also, it's really cool how the icon gets smaller to a minimum size as you transition away from a screen.
Maybe there's some 3rd party library that provides a protocol and it's relatively easy to implement, but I can't find it. If there's not, I'm thinking it's just one view controller with many views side by side and as you drag your finger, it calculates where each view needs to be..and what color every pixel needs to be.
I imagine you already have it by now. But in case you still have any doubts, I made gist that does the animation: https://gist.github.com/mnmaraes/9536364
Anyways, have fun.
It's a fade animation, so:
[UIView animateWithDuration:0.5
delay:0.0
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{
_backgroundImageView.image = nextImage;
} completion:nil];
should do the trick for the background part.
For the foreground/icon part you can animate the transform to scale and translate the views as they slide in and out.
UI animations are great, very easy to use, and are used allot. The only one problem I have with it is that while the animation is moving, the view in not receiving any user interaction.
For example, if a have a UIButton that animates every time it's shown, but the user will not be able to click on it until the animation is over.
//This is a UIButton:
- (void)animationApear
{
CGRect frameSelf = self.frame;
frameSelf.origin.y -= frameSelf.size.height;
[UIView animateWithDuration:1.0 delay:0
usingSpringWithDamping:0.8 initialSpringVelocity:0
options:0
animations:^{
[self setFrame:frameSelf];
} completion:nil];
}
Is there any way to deal with this issue?
Thanks!
You need to supply the option UIViewAnimationOptionAllowUserInteraction.
Also, depending on your view architecture, if the button is within the animated view, or a subview thereof, then the actual location of the button isn't moving. Only the presentation layer of the button is moving, so that is why the button may not be receiving taps. A good test is to tap where the button was when the animation started (and make sure the option UIViewAnimationOptionAllowUserInteraction is on) to see if it is still receiving taps.
On solution, when you actually need to animate buttons, is to make repeated short transforms (CGAffineTransforms, for example) and have those movements in aggregate, create the visual effect of the animation. Though in this case the button itself will move, rather than simply it's presentation.
I am developing an application which needs to decrease the width of imageview to 0 from 320 in a 1hour time. for this i am using following code
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:3600];
newRect.size.width = 0;
imgView.frame = newRect;
[UIView commitAnimations];
it is works fine if we stay in same view controller,after animation starts if the user navigate to some other viewcontoller, How to handle the animation.
Along with this i have one more issue- during the animation the image in imageview is looks like shrink as throughout the animation i am using same image ,So i want to change the image in imageView during the animation How can i achieve this.
Is there any other way to do this apart form the animation.
Any Help is Appreciated.
The life cycle of the controllers and views will not allow you to do this so simply. The objects you are using can and will be deallocated by the system if they are not currently needed anymore, so the animation you started is essentially discarded with it.
You will have to store the progress of your animation somewhere, e. g. in a file or a CoreData database to have it persistent across the instantiations of that view. Depending on the exact situation, it might be sufficient to store the start time of the animation once it begins. Then, in viewWillAppear you could load it and calculate how much progress into that one hour has been made and start a new animation from that point. To the user it would appear as if the animation had proceeded in the background.