Giter VIP home page Giter VIP logo

jxydatepicker's Introduction

JxyDatePicker

因项目需求,需要用到一个时间选择器,设置最大可选时间与最小可选时间,其它无效不可选的时间需要‘干’掉!!!苦于找了一堆别人自定义的时间选择器,并没有符合要求的。故而:自己写了一个。只分享给有需要的人(demo已附上)。 先看效果:

image

@protocol JXYDatePickerDelegate <NSObject>
@optional
//选中日期
-(void)didSelectedDateString:(NSString *)dateString;
//取消日期
-(void)cancelDatePicker;
@end
@interface JXYDatePicker : UIView
//代理
@property (nonatomic ,weak)id<JXYDatePickerDelegate>delegate;
-(instancetype)initWithFrame:(CGRect)frame WithMinimumDate:(NSDate *)minimumDate maximumDate:(NSDate *)maximumDate;
@end

简单易懂!定义了一个代理及两个方法,分别对应确定按钮与取消按钮的点击操作。 公开了一个方法,即初始化这个时间选择器的方法,参数方别对应:frame,最小日期,最大日期。

简单使用:

实现完了就可以用啦,几句代码就可以搞定:

NSDate *minimumDate = [NSDate dateWithTimeIntervalSinceNow:(24 * 3600 * 7)];
    NSDate *maximumDate = [NSDate dateWithTimeIntervalSinceNow:(24 *3600 *365 *2)];
    _JDatepicker = [[JXYDatePicker alloc]initWithFrame:CGRectMake(0, 100, SCREEN_WIDTH, datePickerH)WithMinimumDate:minimumDate maximumDate:maximumDate];
    _JDatepicker.delegate = self;
    [self.view addSubview:_JDatepicker];

非常希望得到你的指点,如果能够帮到你,我也很欣慰!

jxydatepicker's People

Stargazers

 avatar  avatar MarsGao avatar  avatar yongjing.xiao avatar

Watchers

James Cloos avatar yongjing.xiao avatar

Forkers

lightsun zlhmyl

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.