Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Blur Effect showing in simulator but not on the iPhone

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

like image 627
Armin Scheithauer Avatar asked Dec 06 '25 09:12

Armin Scheithauer


1 Answers

Check if the user hasn't disabled transparency effects:

if !UIAccessibilityIsReduceTransparencyEnabled() {
   //your code for blur

} else {
    //do something else, add a solid color, etc

}
like image 55
TonyMkenu Avatar answered Dec 07 '25 23:12

TonyMkenu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!