【问题标题】:WatchKit Blurred Background ImageWatchKit 模糊的背景图像
【发布时间】:2020-06-30 16:27:32
【问题描述】:

在 Apple 展示的许多手表应用中,它们使用模糊图像作为应用的背景(类似于 iPhone 的 UIEffectView)。我想知道如何在 Xcode 中实现这一点?

我应该使用图像作为背景,顶部有一组吗?

谢谢

【问题讨论】:

    标签: ios xcode image watchkit


    【解决方案1】:

    我相信这种效果是唯一的预制艺术品。可悲的是,您无法获得这种以编程方式制作的效果。上下文菜单是唯一在弹出时会在运行时模糊背景的组件。

    【讨论】:

      【解决方案2】:

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

      在文档中,UIView 不用于 watchOS。

      【讨论】:

      • 我认为那里有一个小错字(is used not used),这使得答案难以理解。
      【解决方案3】:

      您需要使用 UIVisualEffectView 或只是向您已有的视图添加模糊效果,如下所示:

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

      【讨论】:

      • 是否可以将此添加到 WatchKit 应用程序中?
      • 不,您不能将任何 UIView 添加到 WatchKit 应用程序中。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-24
      • 2011-10-22
      • 2018-10-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多