财神随手记账

Square3WithMultiGestureView.m 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. //
  2. // Square3WithMultiGestureView.m
  3. // FoolsparadiseView
  4. //
  5. // Created by foolsparadise on 19/9/2017.
  6. // Copyright © 2017 github.com/foolsparadise All rights reserved.
  7. //
  8. #import "Square3WithMultiGestureView.h"
  9. @interface Square3WithMultiGestureView ()
  10. @property (nonatomic, strong) UIButton *upButton;
  11. @property (nonatomic, strong) UIButton *middleUIButton;
  12. @property (nonatomic, strong) UIButton *downButton;
  13. @end
  14. @implementation Square3WithMultiGestureView
  15. /*
  16. // Only override drawRect: if you perform custom drawing.
  17. // An empty implementation adversely affects performance during animation.
  18. - (void)drawRect:(CGRect)rect {
  19. // Drawing code
  20. }
  21. */
  22. - (instancetype)initWithFrame:(CGRect)frame
  23. {
  24. self = [super initWithFrame:frame];
  25. if (self) {
  26. [self setupUI];
  27. }
  28. return self;
  29. }
  30. - (void)setupUI {
  31. self.layer.masksToBounds = YES;
  32. self.layer.cornerRadius = 12.0;
  33. self.layer.borderWidth = 1;
  34. self.backgroundColor = [UIColor whiteColor];
  35. }
  36. - (void)setUpImageViewString:(NSString *)upImageViewString
  37. {
  38. NSString *resourePath = [[NSBundle mainBundle] resourcePath];
  39. [self.upButton setImage:[UIImage imageWithContentsOfFile:[resourePath stringByAppendingPathComponent:upImageViewString]] forState:UIControlStateNormal];
  40. [self.upButton sizeToFit];
  41. }
  42. - (void)setMiddleLableString:(NSString *)middleLableString
  43. {
  44. [self.middleUIButton setTitle:NSLocalizedStringFromTable(middleLableString, @"InfoPlist", nil) forState:UIControlStateNormal];
  45. self.middleUIButton.titleLabel.font = [UIFont systemFontOfSize:14];
  46. [self.middleUIButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  47. }
  48. - (void)setDownImageViewString:(NSString *)downImageViewString
  49. {
  50. NSString *resourePath = [[NSBundle mainBundle] resourcePath];
  51. [self.downButton setImage:[UIImage imageWithContentsOfFile:[resourePath stringByAppendingPathComponent:downImageViewString]] forState:UIControlStateNormal];
  52. [self.downButton sizeToFit];
  53. }
  54. - (UIButton *)upButton
  55. {
  56. if (!_upButton) {
  57. _upButton = [UIButton buttonWithType:UIButtonTypeCustom];
  58. _upButton.backgroundColor = [UIColor whiteColor];
  59. _upButton.layer.borderColor = [UIColor whiteColor].CGColor;
  60. _upButton.layer.borderWidth = 0;
  61. [_upButton.layer setMasksToBounds:YES];
  62. [_upButton.layer setCornerRadius:12.0];
  63. _upButton.tag = 1;
  64. [_upButton addTarget:self action:@selector(click_Button:) forControlEvents:UIControlEventTouchUpInside];
  65. }
  66. return _upButton;
  67. }
  68. - (UIButton *)middleUIButton
  69. {
  70. if (!_middleUIButton) {
  71. _middleUIButton = [UIButton buttonWithType:UIButtonTypeCustom];
  72. _middleUIButton.backgroundColor = [UIColor whiteColor];
  73. _middleUIButton.layer.borderColor = [UIColor whiteColor].CGColor;
  74. _middleUIButton.layer.borderWidth = 0;
  75. [_middleUIButton.layer setMasksToBounds:YES];
  76. [_middleUIButton.layer setCornerRadius:12.0];
  77. _middleUIButton.tag = 0;
  78. [_middleUIButton addTarget:self action:@selector(click_Button:) forControlEvents:UIControlEventTouchUpInside];
  79. }
  80. return _middleUIButton;
  81. }
  82. - (UIButton *)downButton
  83. {
  84. if (!_downButton) {
  85. _downButton = [UIButton buttonWithType:UIButtonTypeCustom];
  86. _downButton.backgroundColor = [UIColor whiteColor];
  87. _downButton.layer.borderColor = [UIColor whiteColor].CGColor;
  88. _downButton.layer.borderWidth = 0;
  89. [_downButton.layer setMasksToBounds:YES];
  90. [_downButton.layer setCornerRadius:12.0];
  91. _downButton.tag = 2;
  92. [_downButton addTarget:self action:@selector(click_Button:) forControlEvents:UIControlEventTouchUpInside];
  93. }
  94. return _downButton;
  95. }
  96. - (void)click_Button:(UIButton *)btn
  97. {
  98. NSInteger tagg = (long)btn.tag;
  99. //NSLog(@"click_upButton %ld", tagg);
  100. if(tagg>0) // 0 not response
  101. {
  102. [self.delegate Square3WithMultiGestureViewDelegate:self.tag withButtonTag:tagg];
  103. }
  104. }
  105. @end