CZPicker 0.4.3

CZPicker 0.4.3

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布时间最后发布2016年8月

陈泽宇维护。



CZPicker 0.4.3

演示

变更日志

以下是最近三个更改:

查看完整变更日志

v0.4.2 - 2016-04-12

  • 改进方向处理,以避免不必要的弹出动画。

v0.4.1 - 2016-04-10

  • 从podspec文件中删除undle资源设置。

v0.4.0 - 2016-04-09

  • 添加pickerWidth来设置选择器宽度。

使用

CZPicker可通过CocoaPods获得。要安装它,只需将以下行添加到您的Podfile中

pod "CZPicker"

要运行示例项目,首先从repo中克隆,然后在Example目录中运行pod install

Swift

如果您正在使用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创建并支持。