0
votes

I present a view controller(B) over another(A) where I want the background of B to be transparent so that A is still visible in the background.

Therefore, before presenting B, it's modalPresentationStyle is set to be .overCurrentContext and B has view.backgroundColor = UIColor.clear so that the transparent background is present.

However when I dismiss B and return back to A, methods of A like viewDidAppear, viewWillAppear, etc. does not get re-triggered.

If I change the above modalPresentationStyle to .fullScreen, viewWillAppear and such will get re-triggered when returned back to A but this time, I lose the transparent background.

All in all, how can I achieve both a transparent background on the presented view and re-trigger methods such as viewDidAppear on A when I return back to A?

1

1 Answers

2
votes

When you present full screen the presenting view is removed from view - so there is nothing to see through your transparent view. So this method will not work for you.

When you present over the current context the presenting view remains - but that is why viewDidAppear etc do not get called - it never went away so it has not re-appeared.

Instead of viewDidAppear use another method of detecting that your transparent view has been dismissed, such as an unwind segue or one of the other methods discussed in this SO answer.