将UIViewController呈现为UIModalPresentationFormSheet& UIModalPresentationOverCurrentContext

时间:2015-06-11 11:13:33

标签: ipad ios8 uivisualeffectview

如何在当前上下文中呈现模糊背景的UITableViewController作为表单?

- (void)viewDidLoad {

   self.tableView.backgroundColor = [UIColor clearColor];
   self.tableView.backgroundView = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];
}

在使用UIModalPresentationOverCurrentContext

设置的iPhone上,它可以全屏运行

但对于iPad,如果我想将其显示为表单,则需要将modalPresentationStyle设置为UIModalPresentationFormSheet

如何设置两者?

2 个答案:

答案 0 :(得分:0)

我发现我需要UIModalPresentationPopover使用modalPresentationStyle,然后您可以将视图控制器popoverPresentationColor设置为clearColor

 FAGalleryTableViewController *vc = (FAGalleryTableViewController *)[segue destinationViewController];

        if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ) {
            vc.modalPresentationStyle = UIModalPresentationPopover;
            vc.popoverPresentationController.sourceView = _storeButton;
            vc.popoverPresentationController.backgroundColor = [UIColor clearColor];
            vc.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionDown;
            vc.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    }

答案 1 :(得分:0)

经过如此多的搜索,这对iOS10 +

起作用了
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){
            //IPAD
            CamVC *destination = segue.destinationViewController;
            [destination setModalPresentationStyle:UIModalPresentationFullScreen];
            [destination setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];

        }else{
            // IPHONE
            CamVC *destination = segue.destinationViewController;
            destination.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;
            destination.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
        }