Skip to content

SGPickerView_DatePicker is a collection of PickerView and DatePicker (用起来极其简单、实用; 只需一句代码创建,一句代码传值,一句代码调出)

License

Notifications You must be signed in to change notification settings

easyhappy/SGPickerView_DatePicker

Repository files navigation

SGPickerView_DatePicker 用起来极其简单、实用(只需一句代码创建,一句代码传值,一句代码调出)

  • 将项目中SGPickerView_DatePicker文件夹拖入工程

  • 导入#import "SGPicker.h"头文件

  • 通过 alloc init 方法创建

* 地区的选择

    SGPickerView *pickerView = [[SGPickerView alloc] init];
    
    pickerView.pickerViewType = SGPickerViewTypeCenter; // 默认pickerViewType为SGPickerViewTypeBottom, 要想 pickerViewType 属性起到作用, 一定要在对象方法 show 之前设置
    
    [pickerView show];
    
    pickerView.locationMessage = ^(NSString *str){
    
        self.title = str;
    
    };

* 日期的选择

    SGDatePicker *datePicker = [[SGDatePicker alloc] init];
    
    datePicker.datePickerType = SGPickerViewTypeCenter; // 默认datePickerType为SGPickerViewTypeBottom, 要想日期设置起到作用:一定设在 datePickerMode 属性之前设置

    datePicker.isBeforeTime = YES; 
    
    datePicker.datePickerMode = UIDatePickerModeDate; // 日期一定要设置
    
    __weak typeof(self) weakSelf = self;
    
    [datePicker didFinishSelectedDate:^(NSDate *selectedDate) {
    
        weakSelf.title = [self dateStringWithDate:selectedDate DateFormat:@"yyyy年MM月dd日"]; // 日期设置
        
        weakSelf.title = [self dateStringWithDate:selectedDate DateFormat:@"MM月dd日 HH:mm"]; // 时间设置

    }];
    
    [datePicker show];

About

SGPickerView_DatePicker is a collection of PickerView and DatePicker (用起来极其简单、实用; 只需一句代码创建,一句代码传值,一句代码调出)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published