PickerKit
PickerKit is an iOS framework that streamlines the stock UIPicker into a gesture based UI with a minimalistic look, allowing to effortlessly pick something from a pool of entries(right now it only has support for colors).
Features
- Entries automatically resize based on height of the container (PickerView)
- IBInspectable properties
- Easy to set-up and customize for your own needs
- Entries Collection View Cell based on Generics for ease of customisation
Requirements
- Xcode 10 and later
- iOS 10 and later
- Swift 5 and later
Example
The example application is the best way to see PickerKit
in action. Simply open the PickerKit.xcodeproj
and run the Example
scheme.
Installation
CocoaPods
PickerKit is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'PickerKit'
Carthage
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
To integrate PickerKit into your Xcode project using Carthage, specify it in your Cartfile
:
github "Alexandru Turcanu/PickerKit"
Run carthage update
to build the framework and drag the built PickerKit.framework
into your Xcode project.
On your application targets’ “Build Phases” settings tab, click the “+” icon and choose “New Run Script Phase” and add the Framework path as mentioned in Carthage Getting started Step 4, 5 and 6
Swift Package Manager
To integrate using Apple's Swift Package Manager, add the following as a dependency to your Package.swift
:
dependencies: [
.package(url: "https://github.com/Pondorasti/PickerKit.git", from: "1.0.0")
]
Manually
If you prefer not to use any of the aforementioned dependency managers, you can integrate PickerKit into your project manually. Simply drag the Sources
Folder into your Xcode project.
Usage
Creating a PickerView
Creating a PickerView is as easy as just giving an array of UIColors. The view's contents, color entries, will resize accordingly to the PickerView's height. This view needs to infer it's height and width from the parent in order to work properly.
let colorPickerView = PickerView(
colorEntries: [UIColor.red, UIColor.blue, UIColor.purple, UIColor.orange, UIColor.green]
)
Retrieving the selected color, this value is accesible in the selectedEntry property. Setting this value to a index in range of the colors array will automatically animate and scroll to that index.
colorPickerView.selectedEntry = 2
Customizing the Appearance
A Boolean value that controls whether the fade out gradient is visible. Default value is true.
colorPickerView.shouldFadeOutView = true
A floating-point value that determines the radius difference between the entry item and the focus ring. Default value is 10.
colorPickerView.focusRingRadiusDelta = 10
A floating-point value that determines the spacing between each entry view. Default value is 12.
colorPickerView.lineSpacing = 12
Notes
At the moment the framework does not support high customizability nor deep access control over it, but any feature request is kindly appreciated.
Contributing
Thank you for your interest in the project! Contributions are very welcome
Make sure to read these guides before getting started:
If you use PickerKit in your app I'd love to hear about it and feature your app here!
Author
Written by Alexandru Turcanu
License
PickerKit is available under the MIT license. See the LICENSE file for more info.