【问题标题】:Blur Background for iOS14 WidgetsiOS 14 小部件的模糊背景
【发布时间】:2021-03-08 23:14:56
【问题描述】:

我创建了一些 iOS14 小部件,并为其设置了一个带有自定义图像的矩形作为背景。 它有一个角半径和一个边距。

结果是我的自定义背景后面的黑色背景,我不知道如何使它像其他小部件一样模糊(例如您在底部图片中看到的快捷方式小部件)。

有人知道我能做什么吗?

更新:

好的,我发现您可以更改 Widget 结构本身的背景颜色。一个不错的方法是从 Widget -> WidgetBackground 在 Assets Catalog 中设置您想要的颜色,并在结构中添加以下代码:

@main
struct CoreDataWidget: Widget {
    let kind: String = "CoreDataWidget"

    var body: some WidgetConfiguration {
        StaticConfiguration(kind: kind, provider: HomeWidgetTimeline()) { entry in
            HomeWidgetEntryView(entry: entry)
                .background(Color("WidgetBackground")) // <- this line

        }
        .configurationDisplayName("OhMyMoney")
        .description("You want to know your current Money and add Expenses quickly with one Touch? \nThen use this Widget!".localized())
        .supportedFamilies([.systemSmall, .systemMedium, .systemLarge])
    }
}

但是有没有办法像上图的 Shortcuts Widget 一样让背景透明?

【问题讨论】:

    标签: swift swiftui background widget ios14


    【解决方案1】:

    这是不可能的:(

    第 3 方应用程序不能为其小部件使用模糊背景

    https://developer.apple.com/forums/thread/655990

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-09
      • 2016-10-31
      • 2021-02-19
      • 2020-10-06
      • 2018-04-24
      • 2013-10-19
      • 2020-10-18
      • 2021-03-05
      相关资源
      最近更新 更多