【发布时间】:2014-10-11 23:32:27
【问题描述】:
我想在我的 iOS8 应用上的图像上切换模糊效果。我知道从这个 if/else 实现的基本思想是错误的,但我不知道如何正确地做到这一点,因为我是新手。任何建议都将被欣然接受。
我还想在模糊图像上切换文本。
我的视图控制器中有这个全局常量
var cont: Int = 0
这是与我图像顶部的按钮相关的@IBAction。
@IBAction func moreInfo(){
/* First, create the blur effect with the "Dark" style.
All the styles are defined in UIBlurEffectStyle */
let blurEffect = UIBlurEffect(style: .Dark)
/* Then create the effect view, using the blur effect that
we just created. The effect is of type UIVisualEffect */
let blurView = UIVisualEffectView(effect: blurEffect)
blurView.frame.size = CGSize(width: 200, height: 250)
blurView.center = CGPoint(x: 160, y: 250)
/* Toggle blur*/
if (cont == 0){
view.addSubview(blurView)
} else {
/* view.removeFromSuperview(blurView)??? */ //Here should be a way to remove the blur
}
}
【问题讨论】:
标签: swift ios8 uiblureffect