iOS : ModalView with background transparent?

前端 未结 6 917
慢半拍i
慢半拍i 2020-12-24 02:14

I want to show a modalview on a viewController. (which has a naviguation controller).

On my view i have text, and a button to show the modalview.

I created

6条回答
  •  轮回少年
    2020-12-24 02:46

    In the PresentingViewController copy the below code under storyboard segue or IBAction.

    SecondViewController *viewController = [self.storyboard   instantiateViewControllerWithIdentifier:@"secondViewController"];
    //SecondViewController *viewController = [SecondViewController alloc]init]; // if you are adding the viewcontroller programatically
    viewController.modalPresentationStyle = UIModalPresentationOverCurrentContext;
        [viewController setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
    [self presentViewController:viewController animated:YES completion:nil];
    

    In the second ViewController do the following steps either by storyboard or through code:

    1. Set the view's (self.view) backgroundcolor to clearcolor and reduce the opacity to 50 %
    2. Now you can realize a semi transparent modal view

提交回复
热议问题