To be able to request permission to the users photo library you need to add this to your Info.plist
<key>NSPhotoLibraryUsageDescription</key>
<string>Why you want to access photo library</string>
import SFImagePicker
let imagePicker = SFImagePicker()
presentImagePicker(imagePicker, animated: true) { (imageManager) in
// User selected an asset. Do something with it. Perhaps begin processing/upload?
} onDeSelction: { (imageManager) in
// User deselected an asset. Cancel whatever you did when asset was selected.
} onFinish: { (imageManagers) in
// User finished selection images.
} onCancel: { (imageManagers) in
// User canceled selection.
}
You need to get the image through acquired imageManager.
let imageView = UIImageView()
let size = CGSize(width: 30, height: 30)
imageManager.request(size: size) { image, _ in
imageView.imageID = imageManager.assetID
imageView.image = image!
}
Users can set the selector to their liking.
picker.settings.selection.max = 3 // maximum number of select
picker.settings.selection.min = 2 // minimum number of select
picker.settings.ui.selectedIndicatorColor = .green // indicator color
picker.settings.ui.selectedIndicatorTextColor = .black // indicator text color
picker.settings.fetchOptions.isSynchronous = false // Synchronous & Asynchronous
picker.settings.fetchOptions.deliveryMode = .fastFormat // delivery mode
To run the example project, clone the repo, and run pod install
from the Example directory first.
SFImagePicker is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'SFImagePicker'
saafaaari, [email protected]
SFImagePicker is available under the MIT license. See the LICENSE file for more info.
Main | Detail |
---|---|