Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Presenting a UIViewController with background transparent in swift 3.0

Tags:

I am presenting a viewController with transparent background. But the components on that viewController is invisible when it is presented. A blank viewController is seen.I have given alpha value and black background color. This is my code when i call the transparent viewController

if indexPath.row==0
{
   let modalViewController = PopUpViewController()
    modalViewController.modalPresentationStyle = .overCurrentContext
    present(modalViewController, animated: true, completion: nil)
 }

enter image description here

But there is a orange color UIView present on this Controller which is invisible Thanks in advanceenter image description here enter image description here

like image 418
Nish Avatar asked Jul 04 '17 09:07

Nish


1 Answers

You just have to present your second Viewcontroller, which has a transparent background, modally. with the following config:

enter image description here

and that's the result :

enter image description here

for those who may not familiar with Opacity: in the situation like this, for transparency, it's better to use Opacity instead of Alpha

enter image description here

like image 173
Mina Avatar answered Oct 11 '22 14:10

Mina