TimeBarCell.m 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. //
  2. // TimeBarCell.m
  3. // jiaPeiC
  4. //
  5. // Created by apple on 16/6/16.
  6. // Copyright © 2016年 JCZ. All rights reserved.
  7. //
  8. #import "TimeBarCell.h"
  9. #import "DateView.h"
  10. @implementation TimeBarCell
  11. - (void)awakeFromNib {
  12. [super awakeFromNib];
  13. // Initialization code
  14. }
  15. -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  16. {
  17. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  18. if (self) {
  19. //初始值
  20. _beginTime = @"开始时间";
  21. _endTime = @"结束时间";
  22. CGFloat x = 20;
  23. UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
  24. btn.frame = CGRectMake(x, 5, 80, 30);
  25. btn.backgroundColor = lineColor;
  26. [btn setTitle:@"开始时间" textColor:contentTextColor font:Font16 fotState:UIControlStateNormal];
  27. [btn borderColor:lineColor width:1 cornorRadios:5];
  28. [btn target:self Tag:1];
  29. [self addSubview:btn];
  30. beginBtn = btn;
  31. [btn addViewWithRect:CGRectMake(x + 82, 20, 16, 1)];
  32. x += 100;
  33. btn = [UIButton buttonWithType:UIButtonTypeCustom];
  34. btn.frame = CGRectMake(x, 5, 80, 30);
  35. btn.backgroundColor = lineColor;
  36. [btn setTitle:@"结束时间" textColor:contentTextColor font:Font16 fotState:UIControlStateNormal];
  37. [btn borderColor:lineColor width:1 cornorRadios:5];
  38. [btn target:self Tag:2];
  39. [self addSubview:btn];
  40. endBtn = btn;
  41. x = kSize.width - 46;
  42. btn = [UIButton buttonWithType:UIButtonTypeCustom];
  43. btn.frame = CGRectMake(x, 7, 26, 26);
  44. [btn setImage:[UIImage imageNamed:@"cancel"] forState:UIControlStateNormal];
  45. [btn target:self Tag:3];
  46. [self addSubview:btn];
  47. }
  48. return self;
  49. }
  50. -(void)showWithRemove:(MyBlockType)remove
  51. {
  52. removeBlock = remove;
  53. }
  54. -(void)btnClick:(UIButton *)sender
  55. {
  56. if (sender.tag == 3) {
  57. if (removeBlock) {
  58. removeBlock(_timeTag);
  59. }
  60. [self removeFromSuperview];
  61. return;
  62. }
  63. DateView* dv = [[DateView alloc] init];
  64. [dv setStyle:1];
  65. [dv showWithComplete:^(NSString *time) {
  66. if (sender.tag == 1) {
  67. _beginTime = time;
  68. [beginBtn setTitle:time forState:UIControlStateNormal];
  69. }
  70. if (sender.tag == 2) {
  71. _endTime = time;
  72. [endBtn setTitle:time forState:UIControlStateNormal];
  73. }
  74. }];
  75. }
  76. -(void)setBeginAndEndTimeWithBeginTime:(NSString *)beginString EndTime:(NSString *)endString
  77. {
  78. _beginTime = beginString;
  79. _endTime = endString;
  80. [beginBtn setTitle:beginString forState:UIControlStateNormal];
  81. [endBtn setTitle:endString forState:UIControlStateNormal];
  82. }
  83. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  84. [super setSelected:selected animated:animated];
  85. }
  86. @end