Created
August 24, 2012 08:19
-
-
Save jlcampana/3447423 to your computer and use it in GitHub Desktop.
Present a modal view controller with size<screen size
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Assuming the view controller's size is WIDTHxHEIGHT | |
//Calling the view Controller: | |
CustomViewController *vc = [[CustomViewController alloc] init]; | |
vc.modalPresentationStyle = UIModalPresentationFormSheet; | |
[self presentModalViewController:vc animated:YES]; | |
//In the view controller: | |
-(void)viewWillAppear:(BOOL)animated | |
{ | |
[[self.view superview] setAlpha:0.0f]; | |
} | |
-(void)viewDidAppear:(BOOL)animated | |
{ | |
CGRect f= [UIScreen mainScreen].bounds; | |
CGPoint p = CGPointMake(round(f.size.width/2.0f), round(f.size.height/2.0f)); | |
[self.view superview].bounds = CGRectMake(0.0f, 0.0f, WIDTH, HEIGHT); | |
[[self.view superview] setCenter:p]; | |
[UIView animateWithDuration:0.1 | |
delay:0.0 | |
options: UIViewAnimationCurveEaseOut | |
animations:^{ | |
[[self.view superview] setAlpha:1.0f]; | |
} | |
completion:^(BOOL finished){ | |
}]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment