HJConfirmPanelViewController.m 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. //
  2. // HJConfirmPanelViewController.m
  3. // HappyJob
  4. //
  5. // Created by Bob on 2019/4/16.
  6. // Copyright © 2019 Bob. All rights reserved.
  7. //
  8. #import "HJConfirmPanelViewController.h"
  9. @interface HJConfirmPanelViewController ()
  10. @property (nonatomic, strong) UIView *contentView;
  11. @property (nonatomic, strong) UIView *lineH;
  12. @property (nonatomic, strong) UIView *lineV;
  13. @end
  14. @implementation HJConfirmPanelViewController
  15. #pragma mark - life cycle
  16. - (void)viewDidLoad {
  17. [super viewDidLoad];
  18. self.view.backgroundColor = [UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:0.6];
  19. [self.view addSubview:self.contentView];
  20. [self.contentView addSubview:self.titleIcon];
  21. [self.contentView addSubview:self.titleLabel];
  22. [self.contentView addSubview:self.cancelButton];
  23. [self.contentView addSubview:self.confirmButton];
  24. [self.contentView addSubview:self.lineH];
  25. [self.contentView addSubview:self.lineV];
  26. [self makeConstraints];
  27. }
  28. - (void)makeConstraints {
  29. [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
  30. make.left.equalTo(self.view).with.offset(30);
  31. make.right.equalTo(self.view).with.offset(-30);
  32. make.centerY.equalTo(self.view);
  33. }];
  34. [self.titleIcon mas_makeConstraints:^(MASConstraintMaker *make) {
  35. make.top.equalTo(self.contentView).with.offset(42);
  36. make.centerX.equalTo(self.contentView);
  37. }];
  38. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  39. make.top.equalTo(self.titleIcon.mas_bottom).with.offset(22);
  40. make.centerX.equalTo(self.contentView);
  41. make.left.equalTo(self.contentView).offset(10);
  42. make.right.equalTo(self.contentView).offset(-10);
  43. }];
  44. [self.lineH mas_makeConstraints:^(MASConstraintMaker *make) {
  45. make.top.equalTo(self.titleLabel.mas_bottom).with.offset(40);
  46. make.left.right.equalTo(self.contentView);
  47. make.height.mas_equalTo(1);
  48. }];
  49. [self.lineV mas_makeConstraints:^(MASConstraintMaker *make) {
  50. make.centerX.equalTo(self.contentView);
  51. make.top.equalTo(self.lineH);
  52. make.size.mas_equalTo(CGSizeMake(1, 46));
  53. }];
  54. [self.cancelButton mas_makeConstraints:^(MASConstraintMaker *make) {
  55. make.top.equalTo(self.lineH.mas_bottom);
  56. make.left.equalTo(self.contentView).with.offset(15);
  57. make.bottom.equalTo(self.contentView);
  58. make.right.equalTo(self.lineV).with.offset(-10);
  59. }];
  60. [self.confirmButton mas_makeConstraints:^(MASConstraintMaker *make) {
  61. make.top.equalTo(self.lineH.mas_bottom);
  62. make.left.equalTo(self.lineV).with.offset(10);
  63. make.bottom.equalTo(self.contentView);
  64. make.right.equalTo(self.contentView).with.offset(-15);
  65. }];
  66. [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
  67. make.bottom.equalTo(self.lineV);
  68. }];
  69. }
  70. #pragma mark - event response
  71. - (void)cancelButtonClicked:(UIButton *)sender {
  72. [self dismissViewControllerAnimated:YES completion:^{
  73. }];
  74. }
  75. #pragma mark - getters and setters
  76. - (UIView *)contentView {
  77. if (_contentView == nil)
  78. {
  79. _contentView = [[UIView alloc] init];
  80. _contentView.layer.cornerRadius = 12;
  81. _contentView.layer.masksToBounds = YES;
  82. _contentView.backgroundColor = [UIColor whiteColor];
  83. }
  84. return _contentView;
  85. }
  86. - (UIView *)lineH {
  87. if (_lineH == nil)
  88. {
  89. _lineH = [[UIView alloc] init];
  90. _lineH.backgroundColor = [UIColor colorWithRed:238/255.0 green:238/255.0 blue:238/255.0 alpha:1.0];
  91. }
  92. return _lineH;
  93. }
  94. - (UIView *)lineV {
  95. if (_lineV == nil)
  96. {
  97. _lineV = [[UIView alloc] init];
  98. _lineV.backgroundColor = [UIColor colorWithRed:238/255.0 green:238/255.0 blue:238/255.0 alpha:1.0];
  99. }
  100. return _lineV;
  101. }
  102. - (UIImageView *)titleIcon {
  103. if (_titleIcon == nil)
  104. {
  105. _titleIcon = [[UIImageView alloc] init];
  106. _titleIcon.image = [UIImage imageNamed:@"panel_del"];
  107. }
  108. return _titleIcon;
  109. }
  110. - (UILabel *)titleLabel {
  111. if (_titleLabel == nil)
  112. {
  113. _titleLabel = [[UILabel alloc] init];
  114. _titleLabel.text = @"是否清除?";
  115. _titleLabel.numberOfLines = 0;
  116. _titleLabel.textAlignment = NSTextAlignmentCenter;
  117. _titleLabel.textColor = COLOR_BACK3;
  118. _titleLabel.font = [UIFont systemFontOfSize:16];
  119. }
  120. return _titleLabel;
  121. }
  122. - (UIButton *)cancelButton {
  123. if (_cancelButton == nil)
  124. {
  125. _cancelButton = [UIButton buttonWithType:UIButtonTypeSystem];
  126. _cancelButton.titleLabel.font = [UIFont systemFontOfSize:16];
  127. [_cancelButton setTitle:@"取消" forState:UIControlStateNormal];
  128. [_cancelButton setTitleColor:[UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1.0] forState:UIControlStateNormal];
  129. [_cancelButton addTarget:self action:@selector(cancelButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
  130. }
  131. return _cancelButton;
  132. }
  133. - (UIButton *)confirmButton {
  134. if (_confirmButton == nil)
  135. {
  136. _confirmButton = [UIButton buttonWithType:UIButtonTypeSystem];
  137. _confirmButton.titleLabel.font = [UIFont systemFontOfSize:16];
  138. [_confirmButton setTitle:@"确认删除" forState:UIControlStateNormal];
  139. [_confirmButton setTitleColor:COLOR_BLUE_4183E1 forState:UIControlStateNormal];
  140. }
  141. return _confirmButton;
  142. }
  143. @end