FMPhotoPicker is a modern, simple and zero-dependency photo picker with an image editor written in Swift for iOS
- Supports both single and multiple selection
- Supports batch selection/deselection by swipe gesture
- Supports preview
- Supports simple image editor with filter and crop functions
- Supports force crop mode
- Supports preview in eclipse bound
- Supports add self-define crop
- Supports add self-define filter
- Supports video player
- Supports customize confirmation view
- Supports customize language
- iOS 9.0+
Insert the following line in your Carthfile:
git "git@github.com:tribalmedia/FMPhotoPicker.git"
and run carthage update FMPhotoPicker
var config = FMPhotoPickerConfig()
For details, see Configuration
let picker = FMPhotoPickerViewController(config: config)
picker.delegate = self
self.present(picker, animated: true)
let editor = FMImageEditorViewController(config: config, sourceImage: image)
editor.delegate = self
self.present(editor, animated: true)
- Implement FMPhotoPickerViewControllerDelegate protocol to handle selected images
func fmPhotoPickerController(_ picker: FMPhotoPickerViewController, didFinishPickingPhotoWith photos: [UIImage])
- Implement FMImageEditorViewControllerDelegate protocol to handle ouput image
func fmImageEditorViewController(_ editor: FMImageEditorViewController, didFinishEdittingPhotoWith photo: UIImage)
mediaTypes
selectMode
maxImage
maxVideo
availableFilters
availableCrops
alertController
forceCropEnabled
eclipsePreviewEnabled
-
mediaTypes
An array indicating the media types to be accessed by the picker controller.
Type:[FMMediaType]
Default:[.image, .video]
-
selectMode
Photo selection mode. It can besingle
ormultiple
mode.
Type: :FMSelectMode
Default ismultiple
-
maxImage
The maximum number of image can be selected. Type:Int
Default:10
-
maxVideo
The maximum number of video can be selected.
Type:Int
Default is10
-
availableFilters
Filters that will be used in editor.
FMPhotoEditor provides some default filters that will be fit to you.
Type:[FMFilterable]
Default: all filters provided by FMPhotoPicker. -
availableCrops
Crop that will be used in editor.
FMPhotoEditor provides some default crops that will be fit to you.
Type:[FMCroppable]
Default: all crops provided by FMPhotoPicker. -
alertController
An alert controller to show confirmation view to user with 2 options: Ok or Cancel.
Type:FMAlertable
Default:FMAlert
-
forceCropEnabled
A bool value indecating whether force mode is enabled.
If set totrue
, only the first crop in theavailableCrops
will be used in the editor.
And that crop's ration will become force crop ratio.
Type:FMAlertable
Default:false
-
eclipsePreviewEnabled
A bool value indicating whether an image in preview screen should be displayed in eclipse bound.
Type:Bool
Default:false
You can freely create your own filter by implement the FMFilterable
protocol.
public protocol FMFilterable {
func filter(image: UIImage) -> UIImage
func filterName() -> String
}
Becareful that the filterName will be used to determine whether two filters is the same.
Make sure that your filter's names is not duplicate with each other and with the default filters that you want to used.
Like filter fuction, FMPhotoPicker provides capability to use your own crop by implement the FMCroppable
protocol.
public protocol FMCroppable {
func crop(image: UIImage, toRect rect: CGRect) -> UIImage
func name() -> String
func icon() -> UIImage
func ratio() -> FMCropRatio?
}
the name()
method also will be used as indentical for the crop.
So make sure you don't have any duplicate crop's name.
You can use your own view style for the confirmation view by implement the FMAlertable
protocol.
public protocol FMAlertable {
func show(in viewController: UIViewController, ok: @escaping () -> Void, cancel: @escaping () -> Void)
}
Made by Tribal Media House with ❤️
FMPhotoPicker is released under the MIT license. See LICENSE for details.