您的位置:首页 > 产品设计 > UI/UE

presentModalViewController使用 UIModalPresentationFormSheet,无法改变frame大小

2015-04-13 11:29 537 查看
TestViewController *testVC = [[TestViewController alloc] initWithNibName:@"TestViewController" bundle:nil];

testVC.modalPresentati*****tyle = UIModalPresentationFormSheet;

testVC.modalTransiti*****tyle = UIModalTransiti*****tyleCrossDissolve;

[self presentModalViewController:testVC animated:YES];

testVC.view.superview.frame = CGRectMake(0, 0, 649, 397);//it's important to do this after presentModalViewController

testVC.view.superview.center = self.view.center;

注意:/it's important to do this after presentModalViewController

可以按以上方法实现。

用另外一种方式,你用的这种是针对整个controller的,你可以用[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft

// forView:theView cache:YES];

iOS8 不能设置frame

UIViewController* modalController = [[UIViewController alloc]init];
modalController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
modalController.modalPresentationStyle =  UIModalPresentationFormSheet;

CGPoint frameSize = CGPointMake([[UIScreen mainScreen] bounds].size.width*0.95f, [[UIScreen mainScreen] bounds].size.height*0.95f);
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat screenWidth = screenRect.size.width;
CGFloat screenHeight = screenRect.size.height;

// Resizing for iOS 8
modalController.preferredContentSize = CGSizeMake(frameSize.x, frameSize.y);
// Resizing for <= iOS 7
modalController.view.superview.frame = CGRectMake((screenWidth - frameSize.x)/2, (screenHeight - frameSize.y)/2, frameSize.x, frameSize.y);

UIViewController *vc = [[[[UIApplication sharedApplication] delegate] window] rootViewController];
[vc presentViewController:modalController animated:YES completion:nil];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: