3 most recent changes are listed here.
Full change logs
- Added
- (UIImage *)czpickerView:(CZPickerView *)pickerView imageForRow:(NSInteger)row
for setting images for every item #20
- Added
animationDuration
for setting duration of animation (both showing and dismissing) #14 - Added
- (NSArray *)selectedRows
to return previously selected items.#10 - Added
setSelectedRows:rows
to pre-set selected items before showing.#15
- Change delegate & dataSource methods names to conform to apple's guideline and avoid error in swift.(methods' names start with 'CZPicker' to 'czpicker')#5
- Make picker higher in landscape mode.
CZPicker is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "CZPicker"
To run the example project, clone the repo, and run pod install
from the Example directory first.
If you are using swift, please refer to CZPicker Swift Demo
To show the picker, simply adding the following code:
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:
#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;
There are a lot of things can be customized, change the following properties to customize the picker of your own:
/** 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;
chenzeyu, [email protected]
CZPicker is available under the MIT license. See the LICENSE file for more info.
CZPicker is created at and supported by Fooyo.sg