Latest 2.0.0
Homepage https://github.com/opalorange/OpalImagePicker
License MIT
Platforms ios 8.0, requires ARC
Authors

OpalImagePicker

Version
License

Description

OpalImagePicker is a multiple selection Image Picker for iOS written in Swift. Meant to be a drop in replacement for UIImagePickerController. Compatible with both Swift and Objective-C.

Swift 3 and Swift 4 Compatibility

  • Swift 4.x: >= 1.5.0 – Latest is 1.7.1 Download here.
  • Swift 3.x: Latest compatible version is 1.4.0 Download here. If you are using CocoaPods be sure to fix the release (pod 'OpalImagePicker', '~> 1.4.0')

Usage

OpalImagePicker is presented much like UIImagePickerController. As a normal View Controller.

let imagePicker = OpalImagePickerController()   
presentOpalImagePickerController(imagePicker, animated: true, 
    select: { (assets) in
        //Select Assets
    }, cancel: {
        //Cancel
    })

Or

let imagePicker = OpalImagePickerController()
imagePicker.imagePickerDelegate = self        
present(imagePicker, animated: true, completion: nil)

OpalImagePicker has three delegate methods to notify you when images have been selected, or the picker has been cancelled. This is only necessary if you choose not to use the presentOpalImagePickerController(_:animated:select:cancel:completion:) function.

optional func imagePicker(_ picker: OpalImagePickerController, didFinishPickingImages images: [UIImage])
optional func imagePicker(_ picker: OpalImagePickerController, didFinishPickingAssets assets: [PHAsset])
optional func imagePickerDidCancel(_ picker: OpalImagePickerController)

OpalImagePicker also allows you to use external images. You may want to use images from Facebook, Instagram, or Twitter for example. You can do this either using the delegate methods below or the following function in Swift presentOpalImagePickerController(_: animated: maximumSelectionsAllowed: numberOfExternalItems: externalItemsTitle: externalURLForIndex: selectImages: selectAssets: selectExternalURLs: cancel: completion:) function.

optional func imagePicker(_ picker: OpalImagePickerController, didFinishPickingImages images: [UIImage])
optional func imagePickerNumberOfExternalItems(_ picker: OpalImagePickerController) -> Int
optional func imagePicker(_ picker: OpalImagePickerController, imageURLforExternalItemAtIndex index: Int) -> URL?    
optional func imagePickerTitleForExternalItems(_ picker: OpalImagePickerController) -> String
optional func imagePicker(_ picker: OpalImagePickerController, didFinishPickingExternalURLs urls: [URL])

OpalImagePicker supports allowing users to customize user interface features

let imagePicker = OpalImagePickerController()

//Change color of selection overlay to white
imagePicker.selectionTintColor = UIColor.white.withAlphaComponent(0.7)

//Change color of image tint to black
imagePicker.selectionImageTintColor = UIColor.black

//Change image to X rather than checkmark
imagePicker.selectionImage = UIImage(named: "x_image")

//Change status bar style
imagePicker.statusBarPreference = UIStatusBarStyle.lightContent

//Limit maximum allowed selections to 5
imagePicker.maximumSelectionsAllowed = 5

//Only allow image media type assets
imagePicker.allowedMediaTypes = Set([PHAssetMediaType.image])

//Change default localized strings displayed to the user
let configuration = OpalImagePickerConfiguration()
configuration.maximumSelectionsAllowedMessage = NSLocalizedString("You cannot select that many images!", comment: "")
imagePicker.configuration = configuration

Installation

OpalImagePicker is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'OpalImagePicker'

Requirements

  • iOS 8.0+
  • Xcode 8.3+
  • Swift 3.1+

Author

OpalOrange made this with ❤

Contribute

We would love you to contribute to OpalImagePicker

License

OpalImagePicker is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "OpalImagePicker",
    "version": "2.0.0",
    "summary": "Multiple Selection Image Picker for iOS written in Swift",
    "homepage": "https://github.com/opalorange/OpalImagePicker",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "opalorange": "[email protected]"
    },
    "requires_arc": true,
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/opalorange/OpalImagePicker.git",
        "tag": "2.0.0"
    },
    "source_files": "OpalImagePicker/Source/*.swift",
    "resource_bundles": {
        "OpalImagePickerResources": [
            "OpalImagePicker/SupportingFiles/**/*.xcassets"
        ]
    },
    "pod_target_xcconfig": {
        "SWIFT_VERSION": "4.2"
    }
}

Pin It on Pinterest

Share This