iOS年月日、时分秒选择器

858 阅读1分钟

本文已参与「新人创作礼」活动,一起开启掘金创作之路。

最美女帝

FQDateTimeSDK

GitHub地址

iOS年月日、时分秒选择器。 在原生控件的基础上增加的选择,和原生PickerView一样的丝滑。

在这里插入图片描述

更新记录

  • 1.0版本 2022-04-21
    1. 增加更多picker模式:支持年月、年月日、时分、时分秒、年月日时分、年月日时分秒
    2. 可自定义字体大小和颜色

功能介绍

  • 支持年月日模式
  • 支持时分秒模式
  • 支持年月日时分秒模式
  • 支持默认时间和最大、最小时间
  • 支持标题的设置,默认为空
  • 字体大小和颜色可以自定义

集成方式

手动集成

  1. 把项目cloneDownload ZIP到本地
  2. 把项目内的FQDateTimeSDK.framework拖到你的项目里 image
  3. 设置 Embed&Sign image

cocoaPods自动集成

这里默认大家对cocoaPods都是信手拈来的

  1. 在Podfile引入
pod 'FQDateTimeSDK'

或者

pod 'FQDateTimeSDK', '~> 1.0'
  1. 在终端 cd 到你的项目根路径
pod install

或者

pod install --no-repo-update

使用案列

  1. 在用到时间选择器的地方引用头文件
#import <FQDateTimeSDK/FQDateTimeSDK.h>
  1. 遵循代理FQDateTimePickerViewDelegate
@interface ViewController ()<FQDateTimePickerViewDelegate>

@end
  1. 实现代理方法
- (void)cancelAction {
    NSLog(@"wuwuFQ:cancelAction");
}

- (void)confirmActionWithDate:(nonnull NSDate *)date withDateString:(nonnull NSString *)dateStr {
    NSLog(@"wuwuFQ:%@---%@", date, dateStr);
}

- (void)scrollActionWithDate:(nonnull NSDate *)date withDateString:(nonnull NSString *)dateStr {
    NSLog(@"wuwuFQ:%@---%@", date, dateStr);
}
  • 年月日选择器
FQDateTimePickerView *pickerView = [[FQDateTimePickerView alloc] init];
pickerView.delegate = self;
pickerView.pickerModel = indexPath.row;
pickerView.cancelColor = [UIColor greenColor];
pickerView.pickerColor = [UIColor systemPinkColor];
pickerView.title = @"wuwuFQ";
pickerView.titleColor = [UIColor redColor];
[pickerView showPicker];

GitHub地址 GitHub地址 GitHub地址