2

Using the iOS Simulator, I'm trying to get the modal to appear over the parent controller with a transparent background. I define the controller as:

var controller = new DailyRewardController();

controller.ModalPresentationStyle = UIModalPresentationStyle.CurrentContext;
controller.View.BackgroundColor = UIColor.Clear;
controller.View.Opaque = true;

PresentViewController (controller, true, null);

The controller initially appears with a transparent background, but as the animation finishes, the screen is now black, as in the following screenshot. Note: ignore the hideous popup; it's only a prototype :-)

enter image description here

This is how it appears after the animation finishes; however, as the animation runs, it's transparent... Any idea why?

Brian Mains
  • 50,520
  • 35
  • 148
  • 257

3 Answers3

1

After finish the animation of presentviewcontroller the root view controller disappears, thats the reason.

RubenVot
  • 188
  • 10
1

Use below code,

var popupVC = this.Storyboard.InstantiateViewController("PopupViewController");
popupVC.ModalPresentationStyle = UIModalPresentationStyle.OverCurrentContext;
NavigationController.PresentModalViewController(popupVC, false);
0

Try removing

controller.View.Opaque = true;

You are setting the background color to "Clear" but then turning Opaque to true which is contradictory.

See here: UIView: opaque vs. alpha vs. opacity

Community
  • 1
  • 1
pnavk
  • 4,552
  • 2
  • 19
  • 43