Answers for "how to detect widget family and return specific view widget swift"

1

how to detect widget family and return specific view widget swift

struct 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.")
        }

    }
}
Posted by: Guest on November-08-2020

Code answers related to "how to detect widget family and return specific view widget swift"

Code answers related to "Swift"

Browse Popular Code Answers by Language