我想创建一个模糊效果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 操作系统是 8.1.2
检查用户是否没有禁用透明效果:
if !UIAccessibilityIsReduceTransparencyEnabled() {
//your code for blur
} else {
//do something else, add a solid color, etc
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)