Leo*_*rey 32
该WidgetFamily(苹果文件)作为枚举的一部分,WidgetKit将让你在视图里于各种尺寸开关和相应的调整。将此设置为@Environment变量并打开可用案例:
.systemSmall.systemMedium.systemLargestruct WidgetView : View {
@Environment(\.widgetFamily) var family
@ViewBuilder
var body: some View {
switch family {
case .systemSmall:
Text("Small")
case .systemMedium:
Text("Medium")
case .systemLarge:
Text("Large")
default:
Text("Some other WidgetFamily in the future.")
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4558 次 |
| 最近记录: |