简体   繁体   English

WatchKit 模糊背景图像

[英]WatchKit Blurred Background Image

In a number of watch apps demonstrated by Apple they use a blurred image as the background for the app (similar to the UIEffectView for iPhone).在 Apple 演示的许多手表应用程序中,它们使用模糊图像作为应用程序的背景(类似于 iPhone 的 UIEffectView)。 I was wondering how i could achieve this in Xcode?我想知道如何在 Xcode 中实现这一目标?

Should I use an Image as the background with a group on top?我应该使用图像作为背景,顶部有一个组吗?

Thanks谢谢

I believe this effect is an only pre made work of art.我相信这种效果是唯一的预制艺术品。 Sadly you can't have such programmatically made effects.遗憾的是,您不能拥有这种以编程方式制作的效果。 Contextual menus are the only component that runtimely blur the background when it is popped up.上下文菜单是唯一在弹出背景时在运行时模糊背景的组件。

https://developer.apple.com/documentation/uikit/uiview https://developer.apple.com/documentation/uikit/uiview

In document, The UIView is used not used for watchOS.在文档中,UIView 不用于 watchOS。

You need to use a UIVisualEffectView or just add a blur effect to a view you already have like so:您需要使用 UIVisualEffectView 或者只是向您已经拥有的视图添加模糊效果,如下所示:

// Blur Effect
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
UIVisualEffectView *bluredEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
[bluredEffectView setFrame:YOUR_VIEW.bounds];

[YOUR_VIEW addSubview:bluredEffectView];

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

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