iOS 17 小组件报错:Please adopt containerBackground API
使用下面的方法解决了:
代码:
extension View {
func widgetBackground(_ backgroundView: some View) -> some View {
if #available(iOSApplicationExtension 17.0, *) {
return containerBackground(for: .widget) {
backgroundView
}