以下是最近三个更改:
查看完整变更日志
pickerWidth
来设置选择器宽度。CZPicker可通过CocoaPods获得。要安装它,只需将以下行添加到您的Podfile中
pod "CZPicker"
要运行示例项目,首先从repo中克隆,然后在Example目录中运行pod install
如果您正在使用Swift,请参考Swift演示项目。
要显示选择器,只需添加以下代码
CZPickerView *picker = [[CZPickerView alloc] initWithHeaderTitle:@"Fruits"
cancelButtonTitle:@"Cancel"
confirmButtonTitle:@"Confirm"];
picker.delegate = self;
picker.dataSource = self;
[picker show];
并实现dataSource和Delegate方法
#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;
有很多可以定制的内容,更改以下属性以自定义您自己的选择器
/** 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可在MIT许可证下使用。有关更多信息,请参阅LICENSE文件。
CZPicker由Fooyo.sg创建并支持。