最近处理小组件适配iOS 17的时候,运行起来提示错误
"Please adopt containerBackground API"
这里需要对View配置一个 containerBackground,在iOS 17中新增了这个API
containerBackground(_:for:)
Sets the container background of the enclosing container using a view.
这是官方文档Code示例:
struct ContentView: View {
var body: some View {
NavigationStack {
List {
NavigationLink("Blue") {
Text("Blue")
.containerBackground(.blue.gradient, for: .navigation)
}
NavigationLink("Red") {
Text("Red")
.containerBackground(.red.gradient, for: .navigation)
}
}
}
}
}
网友评论