No Description

FKCircleAddView.m 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. //
  2. // FKCircleAddView.m
  3. // FirstLink
  4. //
  5. // Created by ascii on 16/6/12.
  6. // Copyright © 2016年 FirstLink. All rights reserved.
  7. //
  8. #import "FKCircleAddView.h"
  9. @interface FKCircleAddView ()
  10. @property (nonatomic, strong) UIButton *button0;
  11. @property (nonatomic, strong) UIButton *button1;
  12. @end
  13. @implementation FKCircleAddView
  14. /*
  15. // Only override drawRect: if you perform custom drawing.
  16. // An empty implementation adversely affects performance during animation.
  17. - (void)drawRect:(CGRect)rect {
  18. // Drawing code
  19. }
  20. */
  21. - (instancetype)init {
  22. self = [super init];
  23. if (self) {
  24. [self addAllSubviews];
  25. }
  26. return self;
  27. }
  28. #pragma mark - Layout
  29. - (void)addAllSubviews {
  30. [self addSubview:self.button0];
  31. [self.button0 mas_makeConstraints:^(MASConstraintMaker *make) {
  32. make.top.equalTo(self).offset(22);
  33. make.left.equalTo(self).offset(70);
  34. make.size.mas_equalTo(CGSizeMake(80, 80));
  35. }];
  36. [self addSubview:self.button1];
  37. [self.button1 mas_makeConstraints:^(MASConstraintMaker *make) {
  38. make.top.equalTo(self.button0);
  39. make.right.equalTo(self).offset(-70);
  40. make.size.mas_equalTo(CGSizeMake(80, 80));
  41. }];
  42. UILabel *label = [self makeTipeLable:@"添加图片"];
  43. [self addSubview:label];
  44. [label mas_makeConstraints:^(MASConstraintMaker *make) {
  45. make.top.equalTo(self.button0.mas_bottom).offset(14);
  46. make.centerX.equalTo(self.button0);
  47. }];
  48. label = [self makeTipeLable:@"添加商品"];
  49. [self addSubview:label];
  50. [label mas_makeConstraints:^(MASConstraintMaker *make) {
  51. make.top.equalTo(self.button1.mas_bottom).offset(14);
  52. make.centerX.equalTo(self.button1);
  53. }];
  54. }
  55. #pragma mark - Action
  56. - (IBAction)clickButtonAction:(UIButton *)sender {
  57. if (self.clickCallback) {
  58. self.clickCallback(sender.tag);
  59. }
  60. }
  61. #pragma mark - Method
  62. + (CGFloat)height {
  63. return 150;
  64. }
  65. #pragma mark - Property
  66. - (UIButton *)button0 {
  67. if (!_button0) {
  68. _button0 = [UIButton buttonWithType:UIButtonTypeCustom];
  69. _button0.tag = 0;
  70. [_button0 setBackgroundImage:[UIImage imageNamed:@"CircleAddImage"] forState:UIControlStateNormal];
  71. [_button0 addTarget:self action:@selector(clickButtonAction:) forControlEvents:UIControlEventTouchUpInside];
  72. }
  73. return _button0;
  74. }
  75. - (UIButton *)button1 {
  76. if (!_button1) {
  77. _button1 = [UIButton buttonWithType:UIButtonTypeCustom];
  78. _button1.tag = 1;
  79. [_button1 setBackgroundImage:[UIImage imageNamed:@"CircleAddProduct"] forState:UIControlStateNormal];
  80. [_button1 addTarget:self action:@selector(clickButtonAction:) forControlEvents:UIControlEventTouchUpInside];
  81. }
  82. return _button1;
  83. }
  84. - (UILabel *)makeTipeLable:(NSString *)text {
  85. UILabel *label = [UILabel new];
  86. label.textColor = UIColorFromRGB(0x333333);
  87. label.font = [UIFont systemFontOfSize:15];
  88. label.text = text;
  89. return label;
  90. }
  91. @end