时间选择器和地点选择器

废话不多说,开整

Picker

时间选择器

- (IBAction)timeBtnClick:(id)sender {
    
    WLDatePickerView * datePicker = [[WLDatePickerView alloc]initWithFrame:self.view.bounds];
    __weak typeof(self)weakself = self;
    [datePicker show:1 after:0 cancelButton:@"取消" doneButton:@"完成"  cancelButtonDidClikedAction:^(NSDate *date) {
        NSDateFormatter * format = [[NSDateFormatter alloc]init];
        [format setDateFormat:@"  yyyy-MM-dd HH:mm"];
        NSString * timeStr = [format stringFromDate:date];
        weakself.timeLabel.text = timeStr;
    }];

}

地点选择器

- (IBAction)selectAdress:(id)sender {
    [self.view endEditing:YES];
    AddressPickView *addressPickView = [AddressPickView shareInstance];
    [self.view addSubview:addressPickView];
    addressPickView.block = ^(NSString *province,NSString *city,NSString *town){
        
        //UITextField *cityTf = [self.view viewWithTag:702];
        
        _province = province;
        _city = city;
        _town = town;
        _userCity = [NSString stringWithFormat:@"%@,%@,%@",province,city,town];
        
        self.addressLabel.text = _userCity;
        self.addressLabel.textColor = [UIColor blackColor];
    };

}

Clone

git clone https://github.com/KingComeFromChina/Picks.git

Use

已经封装好,Clone下来后,直接把WLDatePickerView和AddressPickView拉入项目中

Picture

时间选择器和地点选择器_第1张图片
时间选择器
时间选择器和地点选择器_第2张图片
时间
时间选择器和地点选择器_第3张图片
地点选择器

时间选择器和地点选择器_第4张图片
地点

你可能感兴趣的:(时间选择器和地点选择器)