So you know that thing where you can’t present transparent screens with -presentModalViewController, it always blanks out the view being presented over? Kinda annoying when what you really want is something like this, right?
But it’s not overly difficult to fake it by animating views around, so that’s what we’ve done in the past. But today we had a situation where a full screen view navigated to on the phone was to be a modal view rolled up from the bottom on the iPad, and we really didn’t want to go to the effort of duplicating all the controller logic, so we looked around a bit to see if anyone clever had found a good way to handle the situtation — and as you can no doubt guess from the above shot, we found it:
iOS: Semi-modal date picker for iPhone
Title notwithstanding, it’s not just for date pickers, although the one above is provided; it’s a nice little piece open sourced on github to present any view controller and its bits with translucency where desired, which the author calls “semi-modal”; and pretty much all you have to do is
1) Instead of -presentModalViewController, call
-(void)presentSemiModalViewController:(TDSemiModalViewController*)vc;
2) Instead of -dismissModalViewControllerAnimated, call
-(void)dismissSemiModalViewController:(TDSemiModalViewController*)vc;
And that’s just about it! Well, there’s some hardcoded phone screen sizes in there, but it’s just a couple lines to make it iPad-friendly. Sure beats stacking all your rollup views and their logic in the parent … especially when you’ve got them already written as separate controllers, yep.
h/t: Stack Overflow!
MAR