I have subclassed UINavigationBar so I can create a gradient to fill it. My problem is that when I present the Navigation Controller, while it animates from bottom to the top, the color of the button items on the navigation bar is still blue (the default one) and it only changes as it should when it finishes animating (when the Navigation Controller reaches the top). I have attached to pictures two help you understand what my problem is.
You put your change color code in animated method only so both together doing fine try this.
[UIView beginAnimations:nil context:nil];
[self.navigationController.navigationBar.tintcolor:[uicolor red color]];
[self.navigationController.navigationbaritem same code here only
[UIView commitAnimations];
in some iPhone/iPad Apps you can see screens sliding in and out.
How does the straight slide in/out work?
I could only find Curl and Flip for animation:
UIViewAnimationTransitionFlipFromLeft,
UIViewAnimationTransitionFlipFromRight,
UIViewAnimationTransitionCurlUp,
UIViewAnimationTransitionCurlDown,
not sure what you mean by sliding in and out, perhaps provide an example app with it
I think you mean pushing a view to the left to reveal the next view under it or something similar
-(void) slideView:(UIView *)uiv_slide toReveal:(UIView *)uiv_reveal withDuration:(double)d_duration {
//Add the subview to the ViewController's view
[self.view addSubview:uiv_reveal];
//Bring the view to slide to the front
[self.view bringSubviewToFront:uiv_slide];
//Make an animation to slide the view off the screen
[UIView animateWithDuration:d_duration
animations:^ {
uiv_slide.center = CGPointMake(-1*(uiv_slide.frame.size.width/2), uiv_slide.frame.size.height/2);
}
];
}
hopefully the code helps
If you make your app based on the navigation app template, the transitions for going from view to view will have that slide in/out animation.
Take a look at some custom animations here. This will allow you to animate your views however you want. You can also use the apple navigation controller to build a drill down structure to your apps. Those view will automatically slide transition.
In Apple's official Maps app for the iPhone, there is a small 'page curl' button in the lower-right corner. When you press it, the map itself peels back to reveal some options. I would like to duplicate this effect in my own app.
I'm trying to use UIModalTransitionStylePartialCurl (Added in SDK 3.2). In terms of its layout, my app resembles Apple's official Maps app almost exactly. I can easily get the ENTIRE screen to peel back, revealing another view underneath, but I don't want this. I want ONLY the map view to peel back.
In order to create this effect, you must have a UIViewController that will perform the transition. If I set this UIViewController's view to a small subview somewhere on the screen that does not take up the entire screen, I can get just that subview to peel back. That's great! However, after the second part of the transition (when the page falls back into place), the views are never where they started. Either the view that peeled back will have moved from its original position, or the view that was revealed will have expanded to take up the entire screen.
Is there any obvious mistake that I'm making? I would really appreciate any help!
The code I'm using is really simple. It's basically just:
underMapViewController.modalTransitionStyle = UIModalTransitionStylePartialCurl;
[curlableMapViewController presentModalViewController:underMapViewController animated:YES];
From the Documentation:
UIModalTransitionStylePartialCurl
When the view controller is presented, one corner of the current view curls up to reveal the modal view underneath. On dismissal, the curled up page unfurls itself back on top of the modal view. A modal view presented using this transition is itself prevented from presenting any additional modal views.
This transition style is supported only if the parent view controller is presenting a full-screen view and you use the UIModalPresentationFullScreen modal presentation style. Attempting to use a different form factor for the parent view or a different presentation style triggers an exception.
Although, I haven't got any exception using other presentations than full screen. I was testing out and I get the same problem as you. I found that if my ParentViewController's view is an ImageView and I set the content mode to UIViewContentModeCenter, the view is not resized or moved. Maybe there is a workaround by saving your current view as an image, put it at the top, make the curl, and after you dismiss your modal, rearrange the messed hidden stuff and remove the top image view. I know that it sounds crazy but that is what I would try if I really had to accomplish that requirement.
Hope this helps, Jorge.
How about something like this:
[UIView beginAnimations:#"PartialPageCurlEffect" context:nil];
[UIView setAnimationDuration:0.3];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:myOldSubViewController.view cache:YES];
[myOldSubViewController.view addSubview:myNewViewController.view];
[UIView commitAnimations];
Note: for some views if the views are complex and off-centre there could be artifacts. Changing cache:YES to cache:NO may fix with.
As cprcrack points out, this doesn't answer the original question. However, it's useful information, so with that in mind I'm going to leave it here.
This is actually much simpler than you'd guess.
We'll call the view controllers MapViewController and SettingsViewController. Your problem is you want to peel back part (and only part) of MapViewController to show SettingsViewController.
Here's how you do it:
Use a full size view for both views.
Only put content on the bottom half of SettingsViewController's view.
Use UIModalTransitionStylePartialCurl to transition between them, like you already are.
iOS will detect that you've done this automatically and only peel MapViewController's view back far enough to the bottom half of SettingsViewController's view, which is where all your content is.
If you put content in the top half of SettingsViewController's view, iOS will detect that and peel back MapViewControllers view all the way instead.
Summary: Put content only in the bottom half of your new view. iOS will figure it out.
(I don't think this is documented anywhere, sorry.)
I had a slight hiccough confusing
.modalTransitionStyle
and
.modalPresentationStyle
The first one goes on the TARGET viewController, e.g., the one you want underneath. The second goes on the PARENT viewController, e.g. the one that actually gets distorted by the curl. The OP got this right, but I got it wrong, and it was a frustrating 10 minutes before I figured it out. Throwing it on this post in case it gives someone else the head slap I needed.
I ran into this problem as well. For me the frame of the parent view wasn't mangled until the modal view was dismissed. So I cached the frame before dismissing then restored it right after.
CGRect frame = controllerWithModal.view.frame;
[controllerWithModal dismissModalViewControllerAnimated:YES];
controllerWithModal.view.frame = frame;
Me too had this problem,but i solved it..(dont know its the right way,but its working)
I wanted to had an imageview inside a scrollview,and when the user taps a button inside that scroll view i wanted to curl-up the scroll view and show a tableview in that place.
So i placed a tableview behind scrollview and initialy set it to hidden.when the user taps button
i did
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:frontView cache:YES];
[UIView commitAnimations];
after that removed frontview from view.
Hope that helps..
I believe that Apple's Maps application uses undocumented transitions: mapCurl and mapUncurl. I am not sure there is any way to do exactly what caecus314 wants (which is also the effect I have been trying to duplicate).
UIModalTransitionStylePartialCurl will curl up the whole bottom part of the first view, including the toolbar, which is unlike Apple's Maps app, which only curls up the map and leaves the toolbar in place.
As far as I can tell there is no way to only curl up the map.
Override the viewWillDisappear method of your underMapViewController with something like this:
- (void)viewWillDisappear:(BOOL)animated
{
curlableMapViewController.view.frame = CGRectMake(0.f, 0.f, 320.f, 416.f);
[super viewWillDisappear:animated];
}
That corrects the size of the view of the curlableMapViewController to the know size you specify, which you could save earlier in the viewWillAppear method, for example.
To explain what I'm looking for I'll give an example: In the Contacts app, when you click the Search field in the first row of the table view it will smoothly take over the entire screen (minus the status bar) including the Navigation Controller's title bar.
Edit: I've also realized that I'm pretty sure this is related to the UISearchDisplayController being within a UITableView which is within an NavigationController which is within a TabBarController. The problem is that the search display will only take up the tableviews size and not the navigation controller.
I've mimicked this in my program by using UIView animations and resizing the entire navigation controller's frame to start above the visible screen's view. See below:
-(void)SetNavContTitleVis:(BOOL)ishidden {
[UIView beginAnimations:#"frame" context:nil];
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration: 0.3];
CGRect frameIn;
if (ishidden) {
frameIn = CGRectMake(0,-46,320,480);
} else {
frameIn = CGRectMake(0,0,320,480-46);
}
self.parentViewController.view.frame=frameIn
[UIView commitAnimations];
}
This works fine and gets the job done but it feels like a hack. Is there any simpler way to do this with search display controllers? I feel that this is a hack that will get me into trouble in the future if display sizes change or the Apple tablet comes out etc. I've looked around for a while but haven't found any simple setting that will force the UISearchDisplayController to take up the navigation controller's title bar smoothly.
The search bar should animate like that by default. Check out Apple's sample TableSearch.
I need to customize the page where on any event the customizable "Button menu pane" has been visible from the bottom, just like one of the application "Twitterrific" (please see the screenshot). I've tried to implement through with modalViewController properties but it populate my customizable view on the whole screen and my parent view is disappeared in the background.
Code snippet:
MyCustomizableButtonMenuContoller *buttonMenucontroller =
[[MyCustomizableButtonMenuContoller alloc] init];
// To show my customizable button menu from bottom at parent view on any event.
[self presentModalViewController:buttonMenucontroller animated:YES];
//To hide customizable button menu.
[self dismissModalViewConrollerAnimated:YES];
I've also tried to transparent my customizable button menu view but it doesn't work on my requirement. The UIActionsheet seems to be the one i'm looking for but again is it possible to customize the buttons with images? If there are any other ways to achieve the scenario in the screen shot, please let me know about your findings or ideas.
Screenshot:
Twitterrific screenshot http://scaline3.appspot.com/Button_menu_pane.png
You don't want to use a modal view controller for this. You can't achieve this "partial overlay" effect that way, because the iPhone OS makes several assumptions about the views of nested view controllers.
Instead, you need to create a UIView with several UIButtons inside that is initially hidden off the bottom of your primary view. When the user clicks the customize button, you need to animate the view upwards into place. The panel will be part of your main controller, but your code shouldn't be too much different.
If you're just getting started with Objective-C, you should read the Core Animation documentation. You should be able to animate the view into place with very, very little code. Here's an example:
[UIView beginAnimations:nil context: nil];
[UIView setAnimationDuration: 0.5];
[myDetailPane setFrame:CGRectMake(0, [self bounds].size.height - [myDetailPane bounds].size.height, [myDetailPane bounds].size.width, [myDetailPane bounds].size.height)];
[UIView commitAnimations];
No timers or gradual movement of the view is necessary - the system will take care of it.
Apple's example in their documentation seems to make use of Navigation Controllers. This might give you some help: Using Modal View Controllers
Good luck!