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

来源:互联网 发布:淘宝被扣12分能恢复吗 编辑:程序博客网 时间:2024/04/28 09:39
 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 8modalController.preferredContentSize = CGSizeMake(frameSize.x, frameSize.y); // Resizing for <= iOS 7modalController.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];


0 0
原创粉丝点击