I wanted to create a blur effect on an UIImageView with the code below. The problem is that I can see the BlurEffect when I run it in the Simulator but not when I connect my iPhone, here I can only see a gray background....any ideas?
Here is the code I used:
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var myImageView: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
self.myImageView.image = UIImage(named: "Desert.png")
let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.Light)
let blurView = UIVisualEffectView(effect: blurEffect)
blurView.frame.size = CGSize(width: 375, height: 667)
blurView.center = myImageView.center
self.myImageView.addSubview(blurView)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
I am running on Xcode 6.1.1 (also tried Xcode 6.2!) and my iPhone OS is 8.1.2
Check if the user hasn't disabled transparency effects:
if !UIAccessibilityIsReduceTransparencyEnabled() {
//your code for blur
} else {
//do something else, add a solid color, etc
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With