YOUPAIHRMonthDateVC.m 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. //
  2. // YOUPAIHRMonthDateVC.m
  3. // VQU
  4. //
  5. // Created by xiaohaoran on 2021/11/5.
  6. // Copyright © 2021 MS. All rights reserved.
  7. //
  8. #import "YOUPAIHRMonthDateVC.h"
  9. #import "BRPickerView.h"
  10. @interface YOUPAIHRMonthDateVC ()
  11. @property(nonatomic,strong)UITextField *youpaipdateField;
  12. @property (nonatomic, strong) BRDatePickerView *youpaipdatePickerView;
  13. @property (nonatomic, strong) NSDate *youpaipselectDate;
  14. @end
  15. @implementation YOUPAIHRMonthDateVC
  16. -(void)viewDidLoad{
  17. [super viewDidLoad];
  18. [self youpaifsetupUI];
  19. }
  20. -(void)youpaifsetupUI{
  21. UIView *bottomView = [UIView new];
  22. [self.view addSubview:bottomView];
  23. [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
  24. make.left.right.bottom.offset(0.0f);
  25. make.height.offset(324+SafeHeight-49);
  26. }];
  27. bottomView.backgroundColor = LCBkgColor;
  28. //youpaipheaderView
  29. UIView *youpaipheaderView = [UIView new];
  30. [bottomView addSubview:youpaipheaderView];
  31. [youpaipheaderView mas_makeConstraints:^(MASConstraintMaker *make) {
  32. make.left.mas_equalTo(0);
  33. make.right.mas_equalTo(0);
  34. make.top.mas_equalTo(0);
  35. make.height.mas_equalTo(60);
  36. }];
  37. youpaipheaderView.backgroundColor = HexColorFromRGBA(0x4F4B5B, 0.2);
  38. //title
  39. UILabel *titleLabel = [UILabel new];
  40. [youpaipheaderView addSubview:titleLabel];
  41. [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  42. make.centerX.mas_equalTo(0);
  43. make.top.mas_equalTo(14);
  44. make.width.mas_equalTo(120);
  45. }];
  46. titleLabel.text = @"当前选择";
  47. titleLabel.font = [UIFont systemFontOfSize:14];
  48. titleLabel.textColor = [UIColor whiteColor];
  49. titleLabel.textAlignment = NSTextAlignmentCenter;
  50. //时间
  51. UITextField *youpaipdateField = [UITextField new];
  52. self.youpaipdateField = youpaipdateField;
  53. [youpaipheaderView addSubview:youpaipdateField];
  54. [youpaipdateField mas_makeConstraints:^(MASConstraintMaker *make) {
  55. make.centerX.mas_equalTo(0);
  56. make.top.mas_equalTo(titleLabel.mas_bottom).offset(6);
  57. make.width.mas_equalTo(120);
  58. }];
  59. youpaipdateField.userInteractionEnabled = NO;
  60. titleLabel.textAlignment = NSTextAlignmentCenter;
  61. NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:@"选择时间" attributes:
  62. @{NSForegroundColorAttributeName:[UIColor whiteColor],
  63. NSFontAttributeName:youpaipdateField.font
  64. }];
  65. youpaipdateField.attributedPlaceholder = attrString;
  66. youpaipdateField.textColor = [UIColor whiteColor];
  67. youpaipdateField.font = [UIFont systemFontOfSize:11];
  68. youpaipdateField.textAlignment = NSTextAlignmentCenter;
  69. // 创建选择器容器视图
  70. UIView *containerView = [[UIView alloc]init];
  71. [bottomView addSubview:containerView];
  72. [containerView mas_makeConstraints:^(MASConstraintMaker *make) {
  73. make.top.mas_equalTo(youpaipheaderView.mas_bottom);
  74. make.left.mas_equalTo(0);
  75. make.right.mas_equalTo(0);
  76. make.bottom.mas_equalTo(-SafeHeight);
  77. }];
  78. containerView.backgroundColor = LCBkgColor;
  79. // 4.创建日期选择器
  80. BRDatePickerView *youpaipdatePickerView = [[BRDatePickerView alloc]init];
  81. youpaipdatePickerView.pickerMode = BRDatePickerModeYM;
  82. youpaipdatePickerView.maxDate = [NSDate date];
  83. youpaipdatePickerView.isAutoSelect = YES;
  84. youpaipdatePickerView.showUnitType = BRShowUnitTypeOnlyCenter;
  85. youpaipdatePickerView.resultBlock = ^(NSDate *youpaipselectDate, NSString *selectValue) {
  86. self.youpaipselectDate = youpaipselectDate;
  87. self.youpaipdateField.text = selectValue;
  88. };
  89. containerView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
  90. // 自定义选择器主题样式
  91. BRPickerStyle *customStyle = [[BRPickerStyle alloc]init];
  92. customStyle.pickerColor = [UIColor clearColor];
  93. youpaipdatePickerView.pickerStyle = customStyle;
  94. self.youpaipdatePickerView = youpaipdatePickerView;
  95. customStyle.pickerTextColor = HexColorFromRGBA(0xFFFFFF, 0.2);
  96. customStyle.separatorColor = [UIColor clearColor];
  97. customStyle.selectRowTextColor = [UIColor whiteColor];
  98. customStyle.dateUnitTextColor = [UIColor whiteColor];
  99. // 添加选择器到容器视图
  100. [youpaipdatePickerView addPickerToView:containerView];
  101. //确定按钮
  102. UIButton *submitBtn = [UIButton new];
  103. [self.view addSubview:submitBtn];
  104. [submitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  105. make.centerX.mas_equalTo(0);
  106. make.bottom.mas_equalTo(-SafeHeight);
  107. make.size.mas_equalTo(CGSizeMake(294, 49));
  108. }];
  109. [submitBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(294, 49) FromColors:@[ZYGradientOneColor,ZYGradientTwoColor] ByGradientType:1] forState:UIControlStateNormal];
  110. [submitBtn setTitle:@"确定" forState:UIControlStateNormal];
  111. [submitBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  112. submitBtn.titleLabel.font = LCBoldFont(16);
  113. [submitBtn addTarget:self action:@selector(youpaifsubmitBtnClick) forControlEvents:UIControlEventTouchUpInside];
  114. submitBtn.layer.cornerRadius = 49/2;
  115. submitBtn.layer.masksToBounds = YES;
  116. }
  117. -(void)youpaifsubmitBtnClick{
  118. if (self.youpaipselectDate == nil) {
  119. [ZCHUDHelper showTitle:@"请选择时间"];
  120. return;
  121. }
  122. if (self.youpaipdidSelectMonthTimeBlock) {
  123. self.youpaipdidSelectMonthTimeBlock(self.youpaipdateField.text);
  124. }
  125. }
  126. #pragma mark - JXCategoryListContentViewDelegate
  127. - (UIView *)listView{
  128. return self.view;
  129. }
  130. @end