Skip to content

Instantly share code, notes, and snippets.

@jlcampana
Created August 24, 2012 08:19
Show Gist options
  • Save jlcampana/3447423 to your computer and use it in GitHub Desktop.
Save jlcampana/3447423 to your computer and use it in GitHub Desktop.
Present a modal view controller with size<screen size
//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