Giter Site home page Giter Site logo

opalimagepicker's Introduction

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 4 and 5 Compatibility

  • Swift 5.0: >= 2.1.0 - Latest is 2.1.0 Download here.
  • Swift 4.2: >= 2.0.0 - Latest is 2.0.0 Download here.
  • Swift 4.0: >= 1.5.0 - Latest is 1.7.1 Download here. CocoaPods be sure to fix the release (pod 'OpalImagePicker', '~> 2.1.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, 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: selectAssets: selectExternalURLs: cancel: completion:) function.

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 9.0+
  • Swift 4 to 5.0

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.

opalimagepicker's People

Contributors

opalorange avatar rivera-ernesto avatar snowzurfer avatar michal-olszewski avatar rlindner avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.