Dynamically hiding view in SwiftUI

前端 未结 7 1289
-上瘾入骨i
-上瘾入骨i 2020-12-24 10:41

I\'m trying to conditionally hide a DatePicker in SwiftUI. However, I\'m having any issue with mismatched types:

var datePicker = DatePicker($da         


        
7条回答
  •  鱼传尺愫
    2020-12-24 11:33

    Command-click the view in question and select the Make Conditional option in Beta 5. I did this on one of my views (LiftsCollectionView), and it generated the following:

        if suggestedLayout.size.height > 150 {
          LiftsCollectionView()
        } else {
          EmptyView()
        }
    

提交回复
热议问题