CRMediaPickerController
CRMediaPickerController is a powerful and customizable media picker controller that allows users to select photos and videos from their device’s photo library.
Installation
To install CRMediaPickerController, simply add the following line to your Podfile:
pod 'CRMediaPickerController'
Then, run pod install
command in your terminal.
Usage
To use CRMediaPickerController in your project, follow these steps:
- Import the framework using:
import CRMediaPickerController
- Create an instance of CRMediaPickerController:
let mediaPickerController = CRMediaPickerController()
- Set the delegate:
mediaPickerController.delegate = self
- Present the picker controller:
self.present(mediaPickerController, animated: true, completion: nil)
Delegate Methods
CRMediaPickerController provides the following delegate methods:
mediaPickerController(_:didFinishPickingMediaWithInfo:)
This method is called when the user has finished selecting media. It provides the selected media as well as any associated information.
func mediaPickerController(_ picker: CRMediaPickerController, didFinishPickingMediaWithInfo info: [CRMediaInfo]) {
// Handle the selected media
}
mediaPickerControllerDidCancel(_:)
This method is called when the user cancels the media picking process.
func mediaPickerControllerDidCancel(_ picker: CRMediaPickerController) {
// Handle cancellation
}
Customization
CRMediaPickerController can be customized using the following properties:
allowMultipleSelection
A boolean value that determines whether multiple media selection is allowed. Default value is false
.
maxSelections
An integer value that specifies the maximum number of media items that can be selected. Default value is 1
.
mediaTypes
An array of CRMediaType
values that defines the types of media to be shown in the picker. Default value includes both photos and videos.
presentationStyle
A value of type UIModalPresentationStyle
that determines the presentation style of the picker. Default value is .fullScreen
.
selectionCheckmarkColor
A color value that defines the color of the selection checkmarks. Default value is system blue color.
navigationBarTintColor
A color value that defines the tint color of the navigation bar. Default value is system blue color.
navigationBarBackgroundColor
A color value that defines the background color of the navigation bar. Default value is clear color.
navigationBarTitleTextAttributes
A dictionary of text attributes that defines the appearance of the navigation bar title.
Requirements
- iOS 10.0+
- Swift 5.0+
- Xcode 11.0+
License
CRMediaPickerController is available under the MIT license. See the LICENSE file for more info.