XYApplyAgentSuccessView.m 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //
  2. // XYApplyAgentSuccessView.m
  3. // Starbuds
  4. //
  5. // Created by 翟玉磊 on 2020/1/9.
  6. // Copyright © 2020 翟玉磊. All rights reserved.
  7. //
  8. #import "XYApplyAgentSuccessView.h"
  9. @interface XYApplyAgentSuccessView ()
  10. @property (nonatomic, readwrite, strong) UIView *line;
  11. @property (nonatomic, readwrite, strong) UIButton *applyUnwindButton;
  12. @end
  13. @implementation XYApplyAgentSuccessView
  14. #pragma mark - Public Method
  15. #pragma mark - Private Method
  16. - (instancetype)initWithFrame:(CGRect)frame{
  17. if (self = [super initWithFrame:frame]) {
  18. // 初始化
  19. [self _setup];
  20. // 创建子控件
  21. [self _setupSubViews];
  22. // 布局子控件
  23. [self _makeSubViewsConstraints];
  24. }
  25. return self;
  26. }
  27. #pragma mark - 事件处理Or辅助方法
  28. - (void)applyUnwindButtonAction:(id)sender {
  29. if (self.applyUnwindButtonActionBlock) {
  30. self.applyUnwindButtonActionBlock();
  31. }
  32. }
  33. #pragma mark - Private Method
  34. - (void)_setup{
  35. self.backgroundColor = Color_White;
  36. }
  37. #pragma mark - 创建子控件
  38. - (void)_setupSubViews{
  39. [self addSubview:self.line];
  40. [self addSubview:self.applyUnwindButton];
  41. [self.applyUnwindButton addTarget:self action:@selector(applyUnwindButtonAction:) forControlEvents:UIControlEventTouchUpInside];
  42. }
  43. #pragma mark - 布局子控件
  44. - (void)_makeSubViewsConstraints{
  45. [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.left.right.top.equalTo(self);
  47. make.height.equalTo(@2.0f);
  48. }];
  49. [self.applyUnwindButton mas_makeConstraints:^(MASConstraintMaker *make) {
  50. make.center.equalTo(self);
  51. make.width.equalTo(@160.0f);
  52. make.height.equalTo(@42.0f);
  53. }];
  54. [self.applyUnwindButton addViewBorder:Color_Clear redian:21.0f];
  55. }
  56. - (UIView *)line {
  57. if (!_line) {
  58. _line = [UIView new];
  59. _line.backgroundColor = Color_Background;
  60. }
  61. return _line;
  62. }
  63. - (UIButton *)applyUnwindButton {
  64. if (!_applyUnwindButton) {
  65. _applyUnwindButton = [UIButton createButtonTextColor:Color_White textFont:Font_B(18)];
  66. [_applyUnwindButton setTitle:kLocalizedString(@"申请解约") forState:UIControlStateNormal];
  67. UIImage *image = [UIImage commonRedGradientColorImageWithImgSize:CGSizeMake(160.0f, 42.0f)];
  68. [_applyUnwindButton setBackgroundImage:image forState:UIControlStateNormal];
  69. }
  70. return _applyUnwindButton;
  71. }
  72. @end