0

I wanted to create a modal View Controller that would have a transparent background but when I tried setting the alpha of the background to 0.5 it just made the view behind it completely black. This is because the background views are being removed after the transition.

self.view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
[self setModalPresentationStyle:UIModalPresentationFullScreen];
[self setDefinesPresentationContext:YES];

Then presenting View Controller Code

SecondViewController *alertView = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
[self presentViewController:alertView animated:YES completion:nil];

please look at the link image/linke.gif

1 Answers1

0

Try this code in the action of the button in the firstViewController to change the view controller and present a new class secondViewController

  secondViewController *VC = [self.storyboard instantiateViewControllerWithIdentifier:@"secondViewController"];

    VC.view.backgroundColor=[UIColor colorWithWhite:0 alpha:0.1f];
    VC.modalPresentationStyle=UIModalPresentationOverCurrentContext;
    [self presentViewController:VC animated:NO completion:nil];
Deepraj Chowrasia
  • 1,349
  • 10
  • 20