0

How do I present a UITableViewController with a blurred background as a form sheet over the current context?

- (void)viewDidLoad {

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

It works fine full screen, on iPhones set with UIModalPresentationOverCurrentContext

But for iPad if I want to display it as a form sheet then I need to set modalPresentationStyle to UIModalPresentationFormSheet.

How do I set both?

4

2 回答 2

0

我发现我需要使用UIModalPresentationPopovermodalPresentationStyle然后您可以将视图控制器设置popoverPresentationColorclearColor.

 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;
    }
于 2015-06-13T07:32:08.377 回答
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;
        }
于 2017-12-21T18:11:02.090 回答