2017-01-04 4 views
3

Я вызываю ViewController как popover, когда пользователь нажимает кнопку. В представлении должен быть черный фон с альфа-0,5. Но представление отображается как то на секунду, чем весь фон становится черным без альфы. Любая идея почему?Swift ViewController Background get black with alpha

Вот мой поповер вызов:

let popOver = storyboard?.instantiateViewController(withIdentifier: "popOver") as! ViewControllerPopOver 
    popOver.modalPresentationStyle = .popover 
    self.present(popOver, animated: true, completion: nil) 

Я пытаюсь установить цвет фона в Popovers viewDidLoad() функции с помощью следующего кода:

self.view.backgroundColor = UIColor.black.withAlphaComponent(0.5) 

ответ

2

Для этого установите modalPresentationStyle в overCurrentContext вместо popover.

let popOver = storyboard?.instantiateViewController(withIdentifier: "popOver") as! ViewControllerPopOver 
popOver.modalPresentationStyle = .overCurrentContext 
self.present(popOver, animated: true) 
+1

Thats it, thanks :) –

+0

@PhilippRosengart Welcome mate :) –