Skip to content

ImagePickerView wraps UIImagePickerController for SwiftUI.

License

Notifications You must be signed in to change notification settings

ralfebert/ImagePickerView

Repository files navigation

ImagePickerView

ImagePickerView wraps UIImagePickerController for SwiftUI:

Usage example:

struct ImagePickerExampleView: View {

    @State var showImagePicker: Bool = false
    @State var image: UIImage?

    var body: some View {
        VStack {
            if image != nil {
                Image(uiImage: image!)
                    .resizable()
                    .aspectRatio(contentMode: .fit)
            }
            Button("Pick image") {
                self.showImagePicker.toggle()
            }
        }
        .sheet(isPresented: $showImagePicker) {
            ImagePickerView(sourceType: .photoLibrary) { image in
                self.image = image
            }
        }
    }
}

About

ImagePickerView wraps UIImagePickerController for SwiftUI.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published