Duck
Duck

Reputation: 35953

iphone - not full screen modal

At some part of my code I am using this line

[[self navigationController] pushViewController:myController animated:YES];

This works perfectly and pushes a view, coming from bottom, over the current one, covering the last one completely.

I am wondering if there's a way to make it cover just part of screen. Let's say, just the half bottom of the screen...

Is it possible? I have tried to change the controller's view frame but the size kept coming full screen.

thanks.

Upvotes: 2

Views: 4087

Answers (2)

David Gelhar
David Gelhar

Reputation: 27900

Instead of using a new view controller modally, you could add a new subview to your existing view, using the same view controller.

You can do the "slide in" animation with something like:

[self.view addSubview: newView];

CGRect endFrame = newView.frame; // destination for "slide in" animation
CGRect startFrame = endFrame; // offscreen source

// new view starts off bottom of screen
startFrame.origin.y += self.view.frame.size.height;
self.newImageView.frame = startFrame;

// start the slide up animation
[UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:.3];   
    newView.frame = endFrame; // slide in
[UIView commitAnimations];

Upvotes: 9

Ben
Ben

Reputation: 2992

You can do it in a limited fashion with a modal view controller. Check out the presentation options available under UIModalPresentationStyle in the apple docs.

You will need to be on iOS 3.2 or above to do a modal view controller.

Upvotes: 1

Related Questions