Reputation: 794
How can I make the background of a UIView translucent so that the user can see their (blurred) home screen?
If this is not possible, perhaps I can screenshot the home screen and add a translucency effect. In this case, how do I take a screenshot of the user's home screen?
Apple has tight privacy views (which I support) so I understand that none of the above may be permitted.
Upvotes: 0
Views: 576
Reputation: 11
let vc = ViewController()
vc.modalPresentationStyle = .overFullScreen
self.present(vc, animated: true, completion: nil)
If need translucent effect use,
let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.dark)
blurEffectView = UIVisualEffectView(effect: blurEffect)
blurEffectView.frame = view.bounds
blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
view.addSubview(blurEffectView)
func takeScreenshot(view: UIView) -> UIImageView {
UIGraphicsBeginImageContext(view.frame.size)
view.layer.render(in: UIGraphicsGetCurrentContext()!)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
UIImageWriteToSavedPhotosAlbum(image!, nil, nil, nil)
return UIImageView(image: image)
}
let view = HomeScreen().view
let image = taketakeScreenshot(view)
Upvotes: 1