Tyler Rolfe Tyler Rolfe - 1 month ago 21
Swift Question

UIView background color changing when view controller finishes loading

I'm loading a view controller modally via another view controller and I'm trying to change the background color using:

override func viewDidLoad() {
super.viewDidLoad()

transparentBG.backgroundColor? = UIColor.black.withAlphaComponent(0.4)

// transparentBG is a UIView defined in storyboard
}


While the view is animating into position (sliding up) it maintains the alpha value I set. But once it reaches the top of the screen it removes the alpha component and is changing the color to what looks like the color with the alpha component, so like a gray color, but with no transparency as seen in the image below.

enter image description here

Is there anyway to maintain the alpha component after if finishes loading?

Answer

Step one: Change this to an overFullScreen presentation.

Step two: There is no step two.