Flatten TupleViews using SwiftUI

后端 未结 2 1176
一整个雨季
一整个雨季 2021-01-13 19:38

Ok, SwiftUI was released this week so we\'re all n00bs but... I have the following test code:

var body: some View {
    switch shape {
    case .oneCircle:
          


        
2条回答
  •  一生所求
    2021-01-13 19:46

    You can also use Group which is logical container so won't change anything visual.

     var body: some View {
        Group {
         switch shape {
         case .oneCircle:
            return ZStack {
                Circle().fill(Color.red)
            }
         case .twoCircles:
            return ZStack {
                Circle().fill(Color.green)
                Circle().fill(Color.blue)
            }
         }
        }
    }
    

提交回复
热议问题