SkillAgentSearch skills...

BAPickView

自定义 pickView,多种自定义样式!git 最全的日期选择器!

Install / Use

/learn @BAHome/BAPickView
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

BAPickView

BAHome Team Name CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

BAPickView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'BAPickView'

V1.2.1 版本删除旧版本代码,注意:如需使用旧版本,请固定版本号为 pod 'BAPickView', 1.2.0

Author

boai, sunboyan@outlook.com

License

BAPickView is available under the MIT license. See the LICENSE file for more info.

1、功能及简介

  • 1、城市选择器,三级联动,可返回省市县和精确的经纬度 <br>
  • 2、可以自定义 array 显示,性别选择等【目前只支持单行数据】
  • 3、日期选择器:年月日,可以完全自定义 NSDateFormatter
  • 4、日期选择器:年月,可以完全自定义 NSDateFormatter
  • 5、日期选择器:年周,如:2017年,第21周
  • 6、横竖屏适配完美
  • 7、可以自定义按钮颜色、背景颜色等
  • 8、新增各种展示、消失动画,如:缩放、上下左右展示、消失动画等
  • 9、可以自由设置 pickView 居中或者在底部显示,还可以自由定制 toolbar 居中或者在底部显示 <br>
  • 10、可以自由设置 pickView 字体、字体颜色等内容,注意:日期选择器暂时不能修改字体,有可能被苹果审核不通过,如有特殊需求,可通过 runtime 修改 <br>
  • 11、新增 各种自定义 datePicker:年、年月、年月日、时间等等,你能想到的效果都有 <br>
  • 12、可以自定义 datePicker 的字体颜色、字体、字体大小、背景颜色等 <br>
  • 13、可以自定义 datePicker 的最大、最小年限 <br>
  • 14、可以自定义 datePicker 的 toolBar 位置、字体、背景颜色等
  • 15、可以自定义显示隐藏 分割线和分割线颜色
  • 16、日期选择器新增 最大月份限制(感谢简书网友 @洁简 同学提出的 需求!) <br>
  • 17、日期选择器新增 优化了最大最小年份月份的写法,现在可以自由定义最大最小日期了,详见 demo<br>
  • 18、新增 选中结果直接显示在 工具栏的中间,且可以自定义颜色、字体 <br>
  • 19、日期选择器 新增背景年份水印显示 <br>
  • 20、完美适配 iOS 11 和 iPhone X <br>
  • 21、新增 自定义 datePicker 自定义字体颜色 <br>

2、图片示例

BAPickView.gif BAPickView1.png

3、安装、导入示例和源码地址

  • 1、pod 导入【最新版本:】: <br> pod 'BAPickView' <br> 如果发现 pod search BAPickView 搜索出来的不是最新版本,需要在终端执行 cd 转换文件路径命令退回到 desktop,然后执行 pod setup 命令更新本地spec缓存(可能需要几分钟),然后再搜索就可以了。<br> 具体步骤:
    • pod setup : 初始化
    • pod repo update : 更新仓库
    • pod search BAPickView
  • 2、文件夹拖入:下载demo,把 BAPickView 文件夹拖入项目即可,<br>
  • 3、导入头文件:<br> #import "BAPickView_OC.h"<br>
  • 4、项目源码地址:<br> OC 版 :https://github.com/BAHome/BAPickView<br>

4、BAPickView 的类结构及 demo 示例

BAPickView.png

简单封装效果 及 demo 示例

//
//  BAPickerManger.h
//  BAPickView
//
//  Created by 博爱 on 2021/4/2.
//  此类是简单的二次封装,如有其他自定义选项可以自行单独二次封装

#import <Foundation/Foundation.h>
#import "BAPickerDefine.h"
#import "BAPickerConfigModel.h"

NS_ASSUME_NONNULL_BEGIN

@interface BAPickerManger : NSObject

/// 快速创建 pickerView 单列
/// @param pickerModel 自定义 model
/// @param cb 返回
+ (void)initStringsPickerWithModel:(BAPickerModel *)pickerModel
                                cb:(BAPickerResultBlock)cb;

/// 快速创建 pickerView  单列
/// @param title 中间标题,例如:请选择日期
/// @param strings 数据源
/// @param showResult 是否显示选中结果
/// @param cb 返回
+ (void)initStringsPickerWithTitle:(nullable NSString *)title
                           strings:(NSArray <NSString *>*)strings
                        showResult:(BOOL)showResult
                                cb:(BAPickerResultBlock)cb ;

/// 快速创建 pickerView  单列
/// @param title 中间标题,例如:请选择日期
/// @param titleFont 中间标题文字字体
/// @param strings 数据源
/// @param maskViewBackgroundColor 遮罩背景颜色,默认:[UIColor.blackColor colorWithAlphaComponent:0.3]
/// @param cancleTitle 取消按钮文字
/// @param cancleTitleColor 取消按钮文字颜色
/// @param cancleTitleFont 取消按钮文字字体
/// @param sureTitle 确定按钮文字
/// @param sureTitleColor 确定按钮文字颜色
/// @param sureTitleFont 确定按钮文字字体
/// @param showResult 是否显示选中结果
/// @param cb 返回
+ (void)initStringsPickerWithTitle:(nullable NSString *)title
                         titleFont:(nullable UIFont *)titleFont
                           strings:(NSArray <NSString *>*)strings
           maskViewBackgroundColor:(nullable UIColor *)maskViewBackgroundColor
                       cancleTitle:(nullable NSString *)cancleTitle
                  cancleTitleColor:(nullable UIColor *)cancleTitleColor
                   cancleTitleFont:(nullable UIFont *)cancleTitleFont
                         sureTitle:(nullable NSString *)sureTitle
                    sureTitleColor:(nullable UIColor *)sureTitleColor
                     sureTitleFont:(nullable UIFont *)sureTitleFont
                        showResult:(BOOL)showResult
                                cb:(BAPickerResultBlock)cb;

@end

@interface BAPickerManger (MultipleStrings)

/// 快速创建 pickerView 多列
/// @param pickerModel 自定义 model
/// @param cb 返回
+ (void)initMultipleStringsPickerWithPickerModle:(BAPickerModel *)pickerModel
                                              cb:(BAPickerResultBlock)cb;

/// 快速创建 pickerView 多列
/// @param title 中间标题,例如:请选择日期 
/// @param multipleStringsArray 数据源
/// @param showResult 是否显示选中结果
/// @param cb 返回
+ (void)initMultipleStringsPickerWithTitle:(nullable NSString *)title
                      multipleStringsArray:(NSArray <NSArray *>*)multipleStringsArray
                                showResult:(BOOL)showResult
                                        cb:(BAPickerResultBlock)cb;

/// 快速创建 pickerView 多列
/// @param title 中间标题,例如:请选择日期
/// @param titleFont 中间标题文字字体
/// @param multipleStringsArray 数据源
/// @param multipleTitleArray 顶部标题注释,详见 demo
/// @param maskViewBackgroundColor 遮罩背景颜色,默认:[UIColor.blackColor colorWithAlphaComponent:0.3]
/// @param cancleTitle 取消按钮文字
/// @param cancleTitleColor 取消按钮文字颜色
/// @param cancleTitleFont 取消按钮文字字体
/// @param sureTitle 确定按钮文字
/// @param sureTitleColor 确定按钮文字颜色
/// @param sureTitleFont 确定按钮文字字体
/// @param showResult 是否显示选中结果
/// @param cb 返回
+ (void)initMultipleStringsPickerWithTitle:(nullable NSString *)title
                                 titleFont:(nullable UIFont *)titleFont
                      multipleStringsArray:(NSArray <NSArray *>*)multipleStringsArray
                        multipleTitleArray:(nullable NSArray <NSString *>*)multipleTitleArray
                   maskViewBackgroundColor:(nullable UIColor *)maskViewBackgroundColor
                               cancleTitle:(nullable NSString *)cancleTitle
                          cancleTitleColor:(nullable UIColor *)cancleTitleColor
                           cancleTitleFont:(nullable UIFont *)cancleTitleFont
                                 sureTitle:(nullable NSString *)sureTitle
                            sureTitleColor:(nullable UIColor *)sureTitleColor
                             sureTitleFont:(nullable UIFont *)sureTitleFont
                                showResult:(BOOL)showResult
                                        cb:(BAPickerResultBlock)cb;

@end

@interface BAPickerManger (City)

/// 快速创建 pickerView 城市选择
/// @param cb 返回
+ (void)initCityPickerWithCallBack:(BAPickerCityResultBlock)cb;

/// 快速创建 pickerView 城市选择
/// @param title 中间标题,例如:请选择日期
/// @param showResult 是否显示选中结果
/// @param cb 返回
+ (void)initCityPickerWithTitle:(nullable NSString *)title
                     showResult:(BOOL)showResult
                             cb:(BAPickerCityResultBlock)cb;

@end

@interface BAPickerManger (SystemDateDatePicker)

/// 快速创建 pickerView 日期选择器-系统样式
/// @param datePickerModel 自定义 model
/// @param cb 返回
+ (void)initSystemDatePickerWithModel:(BADatePickerModel *)datePickerModel
                                   cb:(BAPickerResultBlock)cb;

/// 快速创建 pickerView 日期选择器-系统样式
/// @param cb 返回
+ (void)initSystemDatePicker:(BAPickerResultBlock)cb;

/// 快速创建 pickerView 日期选择器-系统样式
/// @param title 中间标题,例如:请选择日期
/// @param datePickerMode datePickerMode description
/// @param showResult 是否显示选中结果
/// @param cb 返回
+ (void)initSystemDatePickerTitle:(nullable NSString *)title
                   datePickerMode:(UIDatePickerMode)datePickerMode
                       showResult:(BOOL)showResult
                               cb:(BAPickerResultBlock)cb;

/// 快速创建 pickerView 日期选择器-系统样式
/// @param title 中间标题,例如:请选择日期
/// @param titleFont 中间标题文字字体
/// @param datePickerMode datePickerMode description
/// @param formatterString formatterString description
/// @param maskViewBackgroundColor 遮罩背景颜色,默认:[UIColor.blackColor colorWithAlphaComponent:0.3]
/// @param cancleTitle 取消按钮文字
/// @param cancleTitleColor 取消按钮文字颜色
/// @param cancleTitleFont 取消按钮文字字体
/// @param sureTitle 确定按钮文字
/// @param sureTitleColor 确定按钮文字颜色
/// @param sureTitleFont 确定按钮文字字体
/// @param showResult 是否显示选中结果
/// @param cb 返回
+ (void)initSystemDatePickerTitle:(nullable NSString *)title
                        titleFont:(nullable UIFont *)titleFont
                   datePickerMode:(UIDatePickerMode)datePickerMode
                  formatterString:(nullable NSString *)formatterString
          maskViewBackgroundColor:(nullable UIColor *)maskViewBackgroundColor
                      cancleTitle:(nullable NSString *)cancleTitle
                 cancleTitleColor:(nullable UIColor *)cancleTitleColor
                  cancleTitleFont:(nullable UIFont *)cancleTitleFont
                        sureTitle:(nullable NSString *)sureTitle
                   sureTitleColor:(nullable UIColor *)sureTitleColor
                    sureTitleFont:(nullable UIFont *)sureTitleFont
                       showResult:(BOOL)showResult
                               cb:(BAPickerResultBlock)cb;

@end

@interface BAPickerManger (CustomDateDatePicker)

/// 快速创建 pickerView 日期选择器-自定义样式
/// @param datePickerModel 自定义 model
/// @param cb 

Related Skills

View on GitHub
GitHub Stars143
CategoryDevelopment
Updated1y ago
Forks32

Languages

Objective-C

Security Score

80/100

Audited on Jun 1, 2024

No findings