ImagePicker for SwiftUI

ImagePickerSwiftUI

ImagePicker for SwiftUI

Useage

set

import ImagePickerSwiftUI

   @State var selectedImage: UIImage?
   @State var showPicker: Bool = false

action

  Button {
    showPicker.toggle()
  } label: {
    Text("Show Image Picker")
  }

show

  .sheet(isPresented: $showPicker) {
    ImagePickerSwiftUI(
      selectedImage: $selectedImage,
      sourceType: .camera // or .photoLibrary
    )
  }

Add Info.plist

    <key>NSCameraUsageDescription</key>
    <string>I'll use it to take pictures.</string>

that’s all

.camera .photoLibrary

GitHub

View Github