How can I make a transition from a UIView to other, like a slide from left or right ?
In addition to PageControl, refer ScrollViewSuite, Scrolling and PhotoScroller. Read the developer documentation for UIScrollView, you wouldn't have had to ask this question.
Write something like this.
[UIView beginAnimations:#"" context:NULL];
//The new position for view1
[myview1 setFrame: CGRectMake(0,0,320,100)];
//The new position for view2
[myview2 setFrame: CGRectMake(320, 0, 320, 100)];
//The animation duration
[UIView setAnimationDuration:2.0];
[UIView setAnimationDelay: UIViewAnimationCurveEaseIn];
[UIView commitAnimations];
Related
I have a Button Add. which will add images from Gallery and Camera.
I want to show this UIVIew from ryt corner and it will expand from 1 to 2 to 3 and to final stat 4. like a baloon . and it will hide as same, from 4 to 3 to 2 to 1.
I have used this animation but this is not what i want ( balloon popover)
/*[UIView beginAnimations:#"" context:NULL];
//The new frame size
[AddImagesToCanvasView setFrame: CGRectMake(224,185,175,132)];
//The animation duration
[UIView setAnimationDuration:2.0];
[UIView setAnimationDelay: UIViewAnimationCurveEaseIn];
[UIView commitAnimations];*/
just change the frames and radious which you want.. also add image in background if you want to display like a ballon with ballon image see code..
UIView *popUpView = [[UIView alloc] initWithFrame:view1.frame]; ///add the frame with requirement e.g view1,view2
popUpView.alpha = 0.0;
popUpView.layer.cornerRadius = 5;
popUpView.layer.borderWidth = 1.5f;
popUpView.layer.masksToBounds = YES;
[self.view addSubview:popUpView];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.4];
[popUpView setAlpha:1.0];
[UIView commitAnimations];
[UIView setAnimationDuration:0.0];
UPDATE:
also see the custom popover view from bellow link..
PopupView
alpopoverview
i hope this help you...
Modal view in iOS appears from bottom of the screen to top, and dismisses from top to bottom of the screen. I would like to know, is there any way i can revert the above and make the model view appear from top of the screen to bottom of it. Thus when it is dismissed it will animate from bottom to top.
Yes why not I think I can offer you a workaround :) ....
First Make a custom UIView and set its coordinates as
View.frame=CGRectMake(0, 0, 320, 0);
Then use Animations to move it from top to bottom and vice-versa like this:-
For making it appear use the following code:-
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:0.25];
View.frame = CGRectMake(0, 0, 320, 460);
[UIView commitAnimations];
For dismissing it use :-
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:0.25];
View.frame = CGRectMake(0, 0, 320, 0);
[UIView commitAnimations];
Hey guys, I still haven't found an answer to this so I think I'll ask you.
[viewOggetto setFrame:aFrame];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[viewOggetto.view setFrame:CGRectMake(0, 0, 320, 480)];
[self.view addSubview:viewOggetto.view];
[UIView commitAnimations];
this is a simple animation for a view to appear in a position and then go full screen.
My question is: how can I make the content of the view follow the animation as well?
Now I have the view frame animating correctly but everything that is inside the view just appears fullscreen instantly.
Thanks.
It's not entirely clear what you want to happen instead of it appearing full-screen instantly. You mean you want it to fade in? Set the alpha property on the subview to 0 and add it to self.view before you start the animation. Then set the alpha property to 1 within the animation.
but what viewOggetto exactly is? if it's a UIView then why to call viewOggetto.view?
is it a UIViewController?
You call both :
[viewOggetto setFrame:aFrame];
[viewOggetto.view setFrame:aFrame];
assuming it's a UIViewController, try this / prova cosi':
[self.view addSubview:viewOggetto.view]; // you need to have it before to animate it
// initial state of the animation:
[viewOggetto.view setFrame:CGRectMake(160, 240, 1, 1)]; // zoom from center
// viewOggetto.view.alpha = 0; // eventually to add a fadeIn animation
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
// ending state of animation:
// viewOggetto.view.alpha = 1; // restore to 1 to eventually to add a fadeIn animation
[viewOggetto.view setFrame:CGRectMake(0, 0, 320, 480)];
[UIView commitAnimations];
if it's a UIView just delete ".view" in every "viewOggetto.view" code
ciao,
luca
Just want to add to Jim's answer. UIView animations animate UIViews from one context to another. If the context doesn't exist before the [UIView beginAnimations:nil context:NULL]; then underside effects will happen. The context wont exist if the view hasn't been added to subview.
I have a tableview and a normal view (let's say view 2) inside a normal view. All made in Interface builder. View 2 is above the tableview and needs to appear animated from above at the loading of the view. When pressing a button, the view disappears again. How can i do this?
thanks
You will have to animate this in a custom animation block. It should be fairly simple..
Set your view's frame so that it is above the screen and not visible:
[yourView setFrame:CGRectMake(0, -480, 320, 480)];
In the animation block just change your view's frame in the animation block:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:GROW_AND_MOVE_ANIMATION_DURATION_SECONDS];
[yourView setFrame:CGRectMake(0, 0, 320, 480)];
[UIView commitAnimations];
To dismiss it/ make it disappear use same animation with the previous frame:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:GROW_AND_MOVE_ANIMATION_DURATION_SECONDS];
[yourView setFrame:CGRectMake(0, -480, 320, 480)];
[UIView commitAnimations];
But before that consider whether you must bring it in from top, cause if bringing it in from bottom as a modal view meets your requirements, you can very easily use UIViewController's method:
- (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated
Good Luck.
how can I implement the animation we see in the iPhone Music app's coverflow screen? when you click on a small view, it flips and scales up to another view? how can I do this? I can use core animation to flip and scale a view, but how can I do the transition to another view? thanks
You need an UIView as Container for the two UIViews (frontside/backside) and then remove/add these from/to the container as subviews while doing the animations in between:
UIView *flipContainer;
UIView *frontSide;
UIView *backSide;
//...
-(void)turnUp
{
[backSide removeFromSuperview];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:flipContainer cache:YES];
[UIView setAnimationDuration:1.0];
CGAffineTransform transform = CGAffineTransformMakeScale(1.2, 1.2);
flipContainer.transform = transform;
[UIView commitAnimations];
[flipContainer addSubview:frontSide];
}
-(void)turnDown
{
[frontSide removeFromSuperview];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:flipContainer cache:YES];
[UIView setAnimationDuration:1.0];
CGAffineTransform transform = CGAffineTransformMakeScale(1, 1);
flipContainer.transform = transform;
[UIView commitAnimations];
[flipContainer addSubview:backSide];
}
I'm trying the exact code you are doing - I get a zoom effect but no turn over. The only difference is that right before the turnUp code I add the flipContainer (with back showing) so then it can be flipped over.
// construct animation container
self.flipContainer = [[FlipContainer alloc] init];
[self.flipContainer.view setFrame:CGRectMake(clickedSquareX, clickedSquareY, 200, 200)];
[self.flipContainer.view addSubview:self.backside.view];
// add animation container
[self.myParentView.view addSubview:self.flipContainer.view];
// PROCEED to your turnUp code
The reason I'm doing this is I have a bunch of images in a horizontal UIScrollView and so to 'simulate' a 200x200 image flipping over and zooming to show detail I add my flipContainer with the backside showing the exact image over the exact spot of the pressed image. It should work shouldn't it? A bit confusing to me is the first line of your turnUp code you do:
[backSide removeFromSuperview];
..which would remove the view I just added.
I'm not sure if this is the right spot to put this question in - sorry if it isn't!