UIColorPickerViewController opens, but does not work and appears incorrect
// swiftui
@State private var showDialog = false
@State private var color: Color = .white
// some code swiftui
Button("Title") {
showDialog = true
}
.sheet(isPresented: $showDialog) {
ColorPickerViewRepresentable(color: $color)
}
// uikit
struct ColorPickerViewRepresentable: UIViewControllerRepresentable {
@Binding var color: Color
func makeUIViewController(context: Context) -> UIColorPickerViewController {
let vc = UIColorPickerViewController()
vc.delegate = context.coordinator
vc.selectedColor = UIColor(color)
vc.supportsAlpha = false
return vc
}
func updateUIViewController(_ uiViewController: UIColorPickerViewController, context: Context) {
uiViewController.selectedColor.resolvedColor(with: UITraitCollection.current)
}
func makeCoordinator() -> Coordinator {
return Coordinator(parent: self)
}
class Coordinator: NSObject, UIColorPickerViewControllerDelegate {
var parent: ColorPickerViewRepresentable
init(parent: ColorPickerViewRepresentable) {
self.parent = parent
}
func colorPickerViewControllerDidFinish(_ viewController: UIColorPickerViewController) {
parent.color = Color(uiColor: viewController.selectedColor)
}
}
}
Post
Replies
Boosts
Views
Activity
XCode 15 RC can't to submit the app for TestFlight or AppStore.
Is it beta?
--
Invalid Toolchain. Your app was built with an unsupported SDK or version of Xcode. If you plan to submit this build to the App Store, make sure you are using the versions listed in https://help.apple.com/xcode/mac/current/#/devf16aefe3b or later. (ID: af090461-0b4e-4c50-8468-c5b6882223b8)