繁体   English   中英

模拟效果显示在模拟器中但不在iPhone上显示

[英]Blur Effect showing in simulator but not on the iPhone

我想用下面的代码在UIImageView上创建一个模糊效果。 问题是,当我在模拟器中运行它时,我可以看到BlurEffect,但是当我连接iPhone时,我看不到它,在这里我只能看到灰色的背景....任何想法? 这是我使用的代码:

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.
}


}

我正在运行Xcode 6.1.1(也试过Xcode 6.2!),我的iPhone OS是8.1.2

检查用户是否未禁用透明效果:

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

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

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM