Alpha for background color not working on iOS

Do you have an idea why the alpha parameter is not working in my view?

  self.view.backgroundColor = UIColor.blackColor().colorWithAlphaComponent(0.4)

please also check this video

Video

thank

+2
source share
3 answers

If you use the storyboard and the current view controller using segue, the segue view attribute that shows you the view controller with a transparent background should be in full screen, as shown in the application.

enter image description here

Then in your view, the controller sets the background color using this:

self.view.backgroundColor = UIColor(white: 0, alpha: 0.4)
+3
source

, , . UIColor , , . UIColor documentation.

colorWithAlphaComponent:

, . , colorWithAlphaComponent: . :

let black = UIColor.blackColor() // 1.0 alpha
self.view.backgroundColor = black.colorWithAlphaComponent(0.5) // 0.5 alpha
+1

ViewController, , UIView UIViewController ViewController .

   [[self view] addSubview:myViewController.view];
+1

All Articles