财神随手记账

Round5WithMultiGestureView.m 5.6KB

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