Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chenzeyu/CZPicker
a picker view shown as a popup for iOS in Objective-C
https://github.com/chenzeyu/CZPicker
ios picker swift
Last synced: 3 months ago
JSON representation
a picker view shown as a popup for iOS in Objective-C
- Host: GitHub
- URL: https://github.com/chenzeyu/CZPicker
- Owner: chenzeyu
- License: mit
- Created: 2015-06-26T19:57:16.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-03-09T15:13:29.000Z (8 months ago)
- Last Synced: 2024-04-24T14:50:52.224Z (6 months ago)
- Topics: ios, picker, swift
- Language: Objective-C
- Size: 2.2 MB
- Stars: 526
- Watchers: 19
- Forks: 90
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ios - CZPicker - A picker view shown as a popup for iOS. (UI / PickerView)
- awesome-ios-star - CZPicker - A picker view shown as a popup for iOS. (UI / PickerView)
- awesome-swift-lib-hunt - CZPicker - So beautiful and easy to use single/multi selection support pickerview. (UI)
- awesome-swift-lib-hunt - CZPicker - So beautiful and easy to use single/multi selection support pickerview. (UI)
README
# CZPicker
[![CI Status](http://img.shields.io/travis/chenzeyu/CZPicker.svg?style=flat)](https://travis-ci.org/chenzeyu/CZPicker)
[![Version](https://img.shields.io/cocoapods/v/CZPicker.svg?style=flat)](http://cocoapods.org/pods/CZPicker)
[![License](https://img.shields.io/cocoapods/l/CZPicker.svg?style=flat)](http://cocoapods.org/pods/CZPicker)
[![Platform](https://img.shields.io/cocoapods/p/CZPicker.svg?style=flat)](http://cocoapods.org/pods/CZPicker)## Demo
![](demo.gif)## Change Log
3 most recent changes are listed here.Full [change logs](CHANGELOG.md)
### v0.4.3 - 2016-08-12
- Added ```- (void)czpickerViewWillDisplay:(CZPickerView *)pickerView;```
- Added ```- (void)czpickerViewDidDisplay:(CZPickerView *)pickerView;```
- Added ```- (void)czpickerViewWillDismiss:(CZPickerView *)pickerView;```
- Added ```- (void)czpickerViewDidDismiss:(CZPickerView *)pickerView;```
- Added ```- (void)reloadData``` to reload picker.
- Added ```- (void)showInContainer:(id)container```.### v0.4.2 - 2016-04-12
- Improve orientation handler to avoid unnecessary pop up animations.### v0.4.1 - 2016-04-10
- Remove bundle resources setting in podspec file.## Usage
CZPicker is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:```ruby
pod "CZPicker"
```To run the example project, clone the repo, and run `pod install` from the Example directory first.
### Swift
If you are using swift, please refer to swift demo project.To show the picker, simply adding the following code:
```objective-c
CZPickerView *picker = [[CZPickerView alloc] initWithHeaderTitle:@"Fruits"
cancelButtonTitle:@"Cancel"
confirmButtonTitle:@"Confirm"];
picker.delegate = self;
picker.dataSource = self;
[picker show];
```
and implement the dataSource and Delegate methods:```objective-c
#prama mark - CZPickerViewDataSource@required
/* number of items for picker */
- (NSInteger)numberOfRowsInPickerView:(CZPickerView *)pickerView;@optional
/*
Implement at least one of the following method,
czpickerView:(CZPickerView *)pickerView
attributedTitleForRow:(NSInteger)row has higer priority
*//* attributed picker item title for each row */
- (NSAttributedString *)czpickerView:(CZPickerView *)pickerView
attributedTitleForRow:(NSInteger)row;/* picker item title for each row */
- (NSString *)czpickerView:(CZPickerView *)pickerView
titleForRow:(NSInteger)row;#prama mark - CZPickerViewDelegate
@optional
/** delegate method for picking one item */
- (void)czpickerView:(CZPickerView *)pickerView
didConfirmWithItemAtRow:(NSInteger)row;/** delegate method for picking multiple items,
implement this method if allowMultipleSelection is YES,
rows is an array of NSNumbers
*/
- (void)czpickerView:(CZPickerView *)pickerView
didConfirmWithItemsAtRows:(NSArray *)rows;
/** delegate method for canceling */
- (void)czpickerViewDidClickCancelButton:(CZPickerView *)pickerView;
```## Customization
There are a lot of things can be customized, change the following properties to customize the picker of your own:```objective-c
/** whether to show footer (including confirm and cancel buttons), default NO */
@property BOOL needFooterView;/** whether allow tap background to dismiss the picker, default YES */
@property BOOL tapBackgroundToDismiss;/** whether allow selection of multiple items/rows, default NO, if this
property is YES, then footerView will be shown */
@property BOOL allowMultipleSelection;/** picker header background color */
@property (nonatomic, strong) UIColor *headerBackgroundColor;/** picker header title color */
@property (nonatomic, strong) UIColor *headerTitleColor;/** picker cancel button background color */
@property (nonatomic, strong) UIColor *cancelButtonBackgroundColor;/** picker cancel button normal state color */
@property (nonatomic, strong) UIColor *cancelButtonNormalColor;/** picker cancel button highlighted state color */
@property (nonatomic, strong) UIColor *cancelButtonHighlightedColor;/** picker confirm button background color */
@property (nonatomic, strong) UIColor *confirmButtonBackgroundColor;/** picker confirm button normal state color */
@property (nonatomic, strong) UIColor *confirmButtonNormalColor;/** picker confirm button highlighted state color */
@property (nonatomic, strong) UIColor *confirmButtonHighlightedColor;/** picker's animation duration for showing and dismissing*/
@property CGFloat animationDuration;```
## Author
chenzeyu, [email protected]
## License
CZPicker is available under the MIT license. See the LICENSE file for more info.
## Credits
CZPicker is created at and supported by [Fooyo.sg](http://fooyo.sg)