// // YOUPAIHRMonthDateVC.m // VQU // // Created by xiaohaoran on 2021/11/5. // Copyright © 2021 MS. All rights reserved. // #import "YOUPAIHRMonthDateVC.h" #import "BRPickerView.h" @interface YOUPAIHRMonthDateVC () @property(nonatomic,strong)UITextField *youpaipdateField; @property (nonatomic, strong) BRDatePickerView *youpaipdatePickerView; @property (nonatomic, strong) NSDate *youpaipselectDate; @end @implementation YOUPAIHRMonthDateVC -(void)viewDidLoad{ [super viewDidLoad]; [self youpaifsetupUI]; } -(void)youpaifsetupUI{ UIView *bottomView = [UIView new]; [self.view addSubview:bottomView]; [bottomView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.bottom.offset(0.0f); make.height.offset(324+SafeHeight-49); }]; bottomView.backgroundColor = LCBkgColor; //youpaipheaderView UIView *youpaipheaderView = [UIView new]; [bottomView addSubview:youpaipheaderView]; [youpaipheaderView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.right.mas_equalTo(0); make.top.mas_equalTo(0); make.height.mas_equalTo(60); }]; youpaipheaderView.backgroundColor = HexColorFromRGBA(0x4F4B5B, 0.2); //title UILabel *titleLabel = [UILabel new]; [youpaipheaderView addSubview:titleLabel]; [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.mas_equalTo(0); make.top.mas_equalTo(14); make.width.mas_equalTo(120); }]; titleLabel.text = @"当前选择"; titleLabel.font = [UIFont systemFontOfSize:14]; titleLabel.textColor = [UIColor whiteColor]; titleLabel.textAlignment = NSTextAlignmentCenter; //时间 UITextField *youpaipdateField = [UITextField new]; self.youpaipdateField = youpaipdateField; [youpaipheaderView addSubview:youpaipdateField]; [youpaipdateField mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.mas_equalTo(0); make.top.mas_equalTo(titleLabel.mas_bottom).offset(6); make.width.mas_equalTo(120); }]; youpaipdateField.userInteractionEnabled = NO; titleLabel.textAlignment = NSTextAlignmentCenter; NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:@"选择时间" attributes: @{NSForegroundColorAttributeName:[UIColor whiteColor], NSFontAttributeName:youpaipdateField.font }]; youpaipdateField.attributedPlaceholder = attrString; youpaipdateField.textColor = [UIColor whiteColor]; youpaipdateField.font = [UIFont systemFontOfSize:11]; youpaipdateField.textAlignment = NSTextAlignmentCenter; // 创建选择器容器视图 UIView *containerView = [[UIView alloc]init]; [bottomView addSubview:containerView]; [containerView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(youpaipheaderView.mas_bottom); make.left.mas_equalTo(0); make.right.mas_equalTo(0); make.bottom.mas_equalTo(-SafeHeight); }]; containerView.backgroundColor = LCBkgColor; // 4.创建日期选择器 BRDatePickerView *youpaipdatePickerView = [[BRDatePickerView alloc]init]; youpaipdatePickerView.pickerMode = BRDatePickerModeYM; youpaipdatePickerView.maxDate = [NSDate date]; youpaipdatePickerView.isAutoSelect = YES; youpaipdatePickerView.showUnitType = BRShowUnitTypeOnlyCenter; youpaipdatePickerView.resultBlock = ^(NSDate *youpaipselectDate, NSString *selectValue) { self.youpaipselectDate = youpaipselectDate; self.youpaipdateField.text = selectValue; }; containerView.autoresizingMask = UIViewAutoresizingFlexibleWidth; // 自定义选择器主题样式 BRPickerStyle *customStyle = [[BRPickerStyle alloc]init]; customStyle.pickerColor = [UIColor clearColor]; youpaipdatePickerView.pickerStyle = customStyle; self.youpaipdatePickerView = youpaipdatePickerView; customStyle.pickerTextColor = HexColorFromRGBA(0xFFFFFF, 0.2); customStyle.separatorColor = [UIColor clearColor]; customStyle.selectRowTextColor = [UIColor whiteColor]; customStyle.dateUnitTextColor = [UIColor whiteColor]; // 添加选择器到容器视图 [youpaipdatePickerView addPickerToView:containerView]; //确定按钮 UIButton *submitBtn = [UIButton new]; [self.view addSubview:submitBtn]; [submitBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.mas_equalTo(0); make.bottom.mas_equalTo(-SafeHeight); make.size.mas_equalTo(CGSizeMake(294, 49)); }]; [submitBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(294, 49) FromColors:@[ZYGradientOneColor,ZYGradientTwoColor] ByGradientType:1] forState:UIControlStateNormal]; [submitBtn setTitle:@"确定" forState:UIControlStateNormal]; [submitBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; submitBtn.titleLabel.font = LCBoldFont(16); [submitBtn addTarget:self action:@selector(youpaifsubmitBtnClick) forControlEvents:UIControlEventTouchUpInside]; submitBtn.layer.cornerRadius = 49/2; submitBtn.layer.masksToBounds = YES; } -(void)youpaifsubmitBtnClick{ if (self.youpaipselectDate == nil) { [ZCHUDHelper showTitle:@"请选择时间"]; return; } if (self.youpaipdidSelectMonthTimeBlock) { self.youpaipdidSelectMonthTimeBlock(self.youpaipdateField.text); } } #pragma mark - JXCategoryListContentViewDelegate - (UIView *)listView{ return self.view; } @end