如何在像TuneIn app这样的Watchkit中实现模糊背景图像

时间:2015-05-28 08:27:17

标签: ios iphone watchkit

我想在iWatch应用程序中实现模糊的背景图像。 Watchkit。 像TuneIn这样的许多应用实现了这一点。 有一些答案可以添加模糊视图,但是watchkit不支持addsubview。

TuneIn应用程序显示此效果:https://itunes.apple.com/us/app/tunein-radio/id418987775

我想实现类似的东西。

请帮忙! 提前致谢! 任何建议都将受到高度赞赏。

2 个答案:

答案 0 :(得分:0)

尝试以下,

//only apply the blur if the user hasn't disabled transparency effects
if !UIAccessibilityIsReduceTransparencyEnabled() {
    let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.Dark)
    let blurEffectView = UIVisualEffectView(effect: blurEffect)
    blurEffectView.frame = view.bounds //view is self.view in a UIViewController
    view.addSubview(blurEffectView)
    //if you have more UIViews on screen, use insertSubview:belowSubview: to place it underneath the lowest view

    //add auto layout constraints so that the blur fills the screen upon rotating device
    blurEffectView.setTranslatesAutoresizingMaskIntoConstraints(false)
} else {
    view.backgroundColor = UIColor.blackColor()
}

答案 1 :(得分:0)

他们通过模糊手机上的图像然后将其发送到手表来实现此目的。