Logo

0x3d.Site

is designed for aggregating information.
Welcome
check repository here

FMPhotoPicker

MIT licensed Carthage compatible Pod Compatible Build

FMPhotoPicker is a modern, simple and zero-dependency photo picker with an elegant and customizable image editor

Quick demo

Batch select/deselect
Smooth transitions
Filter
Crop
FMPhotoPickerFMPhotoPickerFMPhotoPickerFMPhotoPicker

Features

  • Support both single and multiple selection
  • Support batch selection/deselection by swipe gesture
  • Support preview
  • Support simple image editor with filter and cropping functions
  • Support force crop mode
  • Support rounded image preview
  • Support adding self-define cropping
  • Support adding self-define filter
  • Support video player
  • Support custom confirmation view
  • Support language customization

Requirements

  • iOS 9.0+

Installation

SwiftPM

dependencies: [
  .package(url: "https://github.com/congnd/FMPhotoPicker.git", .exact("1.3.0")),
]

Carthage

Insert the following line in your Carthfile:

git "[email protected]:congnd/FMPhotoPicker.git"

and run carthage update FMPhotoPicker

CocoaPods

FMPhotoPicker is now available in CocoaPods
You want to add pod 'FMPhotoPicker', '~> 1.3.0' similar to the following to your Podfile:

target 'MyApp' do
  pod 'FMPhotoPicker', '~> 1.3.0'
end

Then run a pod install inside your terminal.

Usage

Create a configuration object

var config = FMPhotoPickerConfig()

For details, see Configuration

Picker

let picker = FMPhotoPickerViewController(config: config)
picker.delegate = self
self.present(picker, animated: true)

From iOS 10, you have to add the Privacy - Photo Library Usage Description into your Info.plist file.

Editor

let editor = FMImageEditorViewController(config: config, sourceImage: image)
editor.delegate = self
self.present(editor, animated: true)

Delegation methods

  • Implement FMPhotoPickerViewControllerDelegate protocol to handle selected photos.
func fmPhotoPickerController(_ picker: FMPhotoPickerViewController, didFinishPickingPhotoWith photos: [UIImage])
func fmPhotoPickerController(_ picker: FMPhotoPickerViewController, didFinishPickingPhotoWith assets: [PHAsset])

If you prefer to receive selected photos in type of PHAsset instead of UIImage then don't forget to set the shouldReturnAsset to true and implement the corresponding delegation method.

  • Implement FMImageEditorViewControllerDelegate protocol to handle ouput image
func fmImageEditorViewController(_ editor: FMImageEditorViewController, didFinishEdittingPhotoWith photo: UIImage)

Configuration

The configuration supports the following parameters:

Reference

  • mediaTypes
    An array that indicates the media types to be accessed by the picker controller.
    Type: [FMMediaType]
    Default: [.image, .video]

  • selectMode
    Photo selection mode that can be in single or multiple mode.
    Type: : FMSelectMode
    Default is multiple

  • maxImage
    The maximum number of images can be selected. Type: Int
    Default: 10

  • maxVideo
    The maximum number of videos can be selected.
    Type: Int
    Default is 10

  • availableFilters
    Filter options that are used in editor. Set this parameter to nil to make the filter menu be unavailable in the editor FMPhotoEditor provides some default filters that will be fit to you.
    Type: [FMFilterable]?
    Default: all filters are provided by FMPhotoPicker.

  • availableCrops
    Crop options that is used in editor. Set this parameter to nil to make the cropping menu be unavailable in the editor FMPhotoEditor provides some default crops that will be fit to you.
    Type: [FMCroppable]? Default: all crops provided by FMPhotoPicker.

You are not allowed to use the editor without giving it at least one crop option or one filter option

  • useCropFirst
    An option that indicates whether the crop menu should be selected by default in the FMImageEditorViewController.
    Type: Bool
    Default: false

  • alertController
    An alert controller to show the confirmation view to an user with 2 options: Ok or Cancel.
    Type: FMAlertable
    Default: FMAlert

  • shouldReturnAsset
    Whether you want FMPhotoPicker returns PHAsset instead of UIImage. FMPhotoPicker chooses a proper delegation method to be invoked when user finishes picking based on this configuration Type: Bool Default: false

  • forceCropEnabled
    A bool value that indicates whether force mode is enabled.
    If true is set, only the first crop in the availableCrops is used in the editor.
    And that crop's ration becomes force crop ratio.
    Type: FMAlertable
    Default: false

  • eclipsePreviewEnabled
    A bool value that indicates whether the preview of image should be displayed in rounded image.
    Type: Bool Default: false

  • strings
    A dictionary that allows you to customize language for your app.
    For details, see FMPhotoPickerConfig.swift
    Type: Dictionary

Customization

Custom filter

You can freely create your own filter by implementing the FMFilterable protocol.

public protocol FMFilterable {
    func filter(image: UIImage) -> UIImage
    func filterName() -> String
}

Be careful that the filterName is used to determine whether the two filters are the same.
Make sure that your filter's names are not duplicated, especially with the default filters that you want to use.

Custom cropping

Similar as filter function, FMPhotoPicker provides the capability to use your own cropping by implementing the FMCroppable protocol.

public protocol FMCroppable {
    func crop(image: UIImage, toRect rect: CGRect) -> UIImage
    func name(string: [String: String]) -> String
    func icon() -> UIImage
    func ratio() -> FMCropRatio?
}

The func name(strings: [String: String]) -> String will receive the strings configuration from configuration object. It allows you customize the cropping while keeping all your language setting in only one place.

The name() method is also used as identifier for the cropping.
Thus, make sure you do not have any duplicate of the cropping name.

Custom alert view controller

You can use your own view style for the confirmation view by implementing the FMAlertable protocol.

public protocol FMAlertable {
    func show(in viewController: UIViewController, ok: @escaping () -> Void, cancel: @escaping () -> Void)
}

Contact

Follow and contact me on Twitter. If you find an issue, just open a ticket. Pull requests are warmly welcome as well.

License

FMPhotoPicker is released under the MIT license. See LICENSE for details.

Swift
Swift
Swift is Apple’s programming language for developing iOS, macOS, and watchOS applications. It’s fast, safe, and easy to learn, with features like type safety and memory management, enabling efficient app development.
GitHub - hirohisa/PageController: Infinite paging controller, scrolling through contents and title bar scrolls with a delay
GitHub - hirohisa/PageController: Infinite paging controller, scrolling through contents and title bar scrolls with a delay
GitHub - Quick/Nimble: A Matcher Framework for Swift and Objective-C
GitHub - Quick/Nimble: A Matcher Framework for Swift and Objective-C
GitHub - roberthein/BouncyLayout: Make. It. Bounce.
GitHub - roberthein/BouncyLayout: Make. It. Bounce.
GitHub - fjcaetano/RxWebSocket: Reactive WebSockets
GitHub - fjcaetano/RxWebSocket: Reactive WebSockets
GitHub - Kitura/Kitura: A Swift web framework and HTTP server.
GitHub - Kitura/Kitura: A Swift web framework and HTTP server.
GitHub - exyte/ProgressIndicatorView: An iOS progress indicator view library written in SwiftUI
GitHub - exyte/ProgressIndicatorView: An iOS progress indicator view library written in SwiftUI
GitHub - rolandleth/LTHRadioButton: A radio button with a pretty animation
GitHub - rolandleth/LTHRadioButton: A radio button with a pretty animation
GitHub - ashishkakkad8/AKSwiftSlideMenu: Slide Menu (Drawer) in Swift
GitHub - ashishkakkad8/AKSwiftSlideMenu: Slide Menu (Drawer) in Swift
GitHub - BastiaanJansen/toast-swift: Customizable Swift Toast view built with UIKit. 🍞
GitHub - BastiaanJansen/toast-swift: Customizable Swift Toast view built with UIKit. 🍞
GitHub - Jintin/Swimat: An Xcode formatter plug-in to format your swift code.
GitHub - Jintin/Swimat: An Xcode formatter plug-in to format your swift code.
GitHub - thoughtbot/Runes: Infix operators for monadic functions in Swift
GitHub - thoughtbot/Runes: Infix operators for monadic functions in Swift
GitHub - tid-kijyun/Kanna: Kanna(鉋) is an XML/HTML parser for Swift.
GitHub - tid-kijyun/Kanna: Kanna(鉋) is an XML/HTML parser for Swift.
GitHub - ParkGwangBeom/Windless: Windless makes it easy to implement invisible layout loading view.
GitHub - ParkGwangBeom/Windless: Windless makes it easy to implement invisible layout loading view.
GitHub - pkluz/PKHUD: A Swift based reimplementation of the Apple HUD (Volume, Ringer, Rotation,…) for iOS 8.
GitHub - pkluz/PKHUD: A Swift based reimplementation of the Apple HUD (Volume, Ringer, Rotation,…) for iOS 8.
GitHub - shtnkgm/ImageTransition: Library for smooth animation of images during transitions.
GitHub - shtnkgm/ImageTransition: Library for smooth animation of images during transitions.
GitHub - hyperoslo/Sugar: :coffee: Something sweet that goes great with your Cocoa
GitHub - hyperoslo/Sugar: :coffee: Something sweet that goes great with your Cocoa
GitHub - mukeshthawani/TriLabelView: A triangle shaped corner label view for iOS written in Swift.
GitHub - mukeshthawani/TriLabelView: A triangle shaped corner label view for iOS written in Swift.
GitHub - yonat/BatteryView: Simple battery shaped UIView
GitHub - yonat/BatteryView: Simple battery shaped UIView
GitHub - suzuki-0000/CountdownLabel: Simple countdown UILabel with morphing animation, and some useful function.
GitHub - suzuki-0000/CountdownLabel: Simple countdown UILabel with morphing animation, and some useful function.
GitHub - sindresorhus/DockProgress: Show progress in your app's Dock icon
GitHub - sindresorhus/DockProgress: Show progress in your app's Dock icon
GitHub - Yalantis/GuillotineMenu: Our Guillotine Menu Transitioning Animation implemented in Swift reminds a bit of a notorious killing machine.
GitHub - Yalantis/GuillotineMenu: Our Guillotine Menu Transitioning Animation implemented in Swift reminds a bit of a notorious killing machine.
GitHub - MrSkwiggs/Netswift: A type-safe, high-level networking solution for Swift apps
GitHub - MrSkwiggs/Netswift: A type-safe, high-level networking solution for Swift apps
GitHub - evermeer/AttributedTextView: Easiest way to create an attributed UITextView (with support for multiple links and from html)
GitHub - evermeer/AttributedTextView: Easiest way to create an attributed UITextView (with support for multiple links and from html)
GitHub - rosberry/texstyle: Format iOS attributed strings easily
GitHub - rosberry/texstyle: Format iOS attributed strings easily
GitHub - ra1028/DiffableDataSources: 💾 A library for backporting UITableView/UICollectionViewDiffableDataSource.
GitHub - ra1028/DiffableDataSources: 💾 A library for backporting UITableView/UICollectionViewDiffableDataSource.
GitHub - Mijick/PopupView: Popups presentation made simple (SwiftUI)
GitHub - Mijick/PopupView: Popups presentation made simple (SwiftUI)
GitHub - envoy/Embassy: Super lightweight async HTTP server library in pure Swift runs in iOS / MacOS / Linux
GitHub - envoy/Embassy: Super lightweight async HTTP server library in pure Swift runs in iOS / MacOS / Linux
GitHub - shima11/FlexiblePageControl: A flexible UIPageControl like Instagram.
GitHub - shima11/FlexiblePageControl: A flexible UIPageControl like Instagram.
GitHub - ChiliLabs/CHIOTPField: CHIOTPField is a set of textfields that can be used for One-time passwords, SMS codes, PIN codes, etc. Mady by @ChiliLabs - https://chililabs.io
GitHub - ChiliLabs/CHIOTPField: CHIOTPField is a set of textfields that can be used for One-time passwords, SMS codes, PIN codes, etc. Mady by @ChiliLabs - https://chililabs.io
GitHub - LeonardoCardoso/SectionedSlider: iOS 11 Control Center Slider
GitHub - LeonardoCardoso/SectionedSlider: iOS 11 Control Center Slider
Swift
More on Swift

Programming Tips & Tricks

Code smarter, not harder—insider tips and tricks for developers.

Error Solutions

Turn frustration into progress—fix errors faster than ever.

Shortcuts

The art of speed—shortcuts to supercharge your workflow.
  1. Collections 😎
  2. Frequently Asked Question's 🤯

Tools

available to use.

Made with ❤️

to provide resources in various ares.