簡體   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