Open view with slide effect from bottom to top on iPhone - iphone

I'm making an application for iPhone (which runs in landscape mode) (OS 3.0), and I want that when I touch a toolbar button it opens a view with a slide effect (similar to the effect when you touch 'Bookmarks' in Mobile Safari's toolbar) from the bottom to the top of the screen. The view is in the same XIB file as the button.
How can I do this?
Thanks in advance.

If you are asking about doing the animation custom here's a snippet that might help.
Lets assume the view "myView" is already added as a subview to the current view.
[myView setFrame:CGRectMake(0, 480, 320, 480)];
[myView setBounds:CGRectMake(0, 0, 320, 480)];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationDelegate:self];
[myView setFrame:CGRectMake(0, 0, 320, 480)];
[UIView commitAnimations];
The important numbers in there are the y positions in the setFrame rect (480 then 0), this moves it from offscreen to onscreen.

[self.tabBarController presentModalViewController:yourSlideController animated:YES];

Related

Transition of Modal View in ios

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];

Content doesn't change correctly on a UIView

Below is my code:
SecondView *sview=[[SecondView alloc] init];
[self.view addSubview:[sview view]];
sview.view.layer.cornerRadius=20;
CGRect rect=sview.view.frame;
CGRect bound=sview.view.bounds;
[sview.view setFrame:CGRectMake(rect.origin.x, btn.frame.origin.y, rect.size.width, 0)];
[sview.view setBounds:CGRectMake(0, 0, bound.size.width, 0)];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[sview.view setFrame:CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height)];
[sview.view setBounds:CGRectMake(0, 0, bound.size.width, bound.size.height)];
[sview.view setTag:10];
[UIView commitAnimations];
I am trying to expand a subview from invisible to visible. In other words, I want to expand a view from one line to a block. The view is a very simple view that I create from IB. There are some buttons on it. When the code runs, the view itself works well. However, the buttons work incorrectly. The buttons move into the view from outside. What I want is the button not to move. Rather, they should expand like the view.
Would someone help me?
Best Regards,
You are only animating the view's frame and bounds, all subviews are not animated with that code. Try using the scale animation, like
sview.view.transform = CGAffineTransformMakeScale(0.01, 0.01);
[UIView beginAnimations:#"animations" context:NULL];
sview.view.transform = CGAffineTransformMakeScale(1.0, 1.0);
[UIView commitAnimations];
This should first shrink your view and all it's subviews to a point, and then expand it in the animation to its original size.

Animating a View Like This Example

I am facing a problem when trying to animate a view. When the user clicks on the advanced search button, it is navigating this view and the animation starts, but it is not correct. How can I animate a view when the user clicks on the advanced search button?
(I want to make this type of animation : )
http://d2o0t5hpnwv4c1.cloudfront.net/041_TopPanelWithJquery/demo/index.html
Are there any good tutorials that will help me in this matter?
Some existing code from a comment
AddSearchView.frame = CGRectMake(10, 65, 310, 148);
//CGRectMake(0, 0, 320, 480);
[self.view addSubview:AddSearchView];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationDuration:0.8];
AddSearchView.frame = CGRectMake(10, 57, 310, 148);
//CGRectMake(0, 480, 320, 480);
[UIView commitAnimations];
You can use UIView's setAnimationDidStopSelector method to call another function once the current animation is complete. I have used this to link animations which heavy relied on timing. For that particular animation, I would try animating the UIView's frame property.
Also consider using CAKeyframeAnimation. http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Reference/CAKeyframeAnimation_class/Introduction/Introduction.html

iPhone xCode | Slide a UIView

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];

Adding a animated view

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.