Swiftpack.co - Package - moifort/swiftUI-photo-library-picker

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.

moifort/swiftUI-photo-library-picker

Photo Library Picker for SwiftUI

GitHub release (latest by date)

Photo Library Picker for SwiftUI

sample sample

Installation with Swift Package Manager

Swift Package Manager is integrated within Xcode 11:

  1. File → Swift Packages → Add Package Dependency...
  2. Paste the repository URL: https://github.com/moifort/swiftUI-photo-library-picker.git
  3. Add NSPhotoLibraryUsageDescription to info.plist

Usage

import SwiftUI
import PhotoLibraryPicker // Add import

struct ContentView : View {
    @State var showActionSheet: Bool = false
    @State var pictures = [Picture](https://raw.github.com/moifort/swiftUI-photo-library-picker/master/)
    
    var body: some View {
        VStack {
            Button(action: {self.showActionSheet.toggle()}) {
                Image(systemName: "plus")
                    .padding()
                    .background(Color.secondary)
                    .mask(Circle())
            }.sheet(isPresented: self.$showActionSheet) {PhotoLibraryPicker(self.$pictures)}
            List {
                ForEach(pictures) { picture in
                    picture.toImage() // You can fix the size by default width: 100, height: 100
                }
            }
        }
    }
}


struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        Group {
            ContentView().environment(\.colorScheme, .dark)
            ContentView()
        }
        
    }
}

Thanks

Github

link
Stars: 41
Last commit: 1 week ago

Releases

1.0.2 - 2021-02-22T13:12:35

Fix

  • fixed errors and warnings in Xcode 12 (#3)

Thanks

  • @RecherJ