Based on this post I've created a custom privacy picker in SwiftUI. The functionality is the following: the button triggers the half modal and based on the choice ("Private", "Public", "Friends") the button label is updated through @State
and @Binding
variables.
Since there is no native half modal in SwiftUI I've used UIViewRepresentable
protocol to create a wrapper of the UIKit view. I've used @ViewBuilder
to to pass the SwiftUI content without creating it in Storyboard. Then I have used the recently introduced UISheetPresentationController
to create the half modal experience in UIKit. To present the modal I've used an UIButton
.