MineBottomView.m 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. //
  2. // MineBottomView.m
  3. // KulexiuForTeacher
  4. //
  5. // Created by 王智 on 2022/8/8.
  6. //
  7. #import "MineBottomView.h"
  8. @interface MineBottomView ()
  9. @property (nonatomic, copy) MineViewCallback callback;
  10. @property (weak, nonatomic) IBOutlet UIView *tradeView;
  11. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *tradeViewHeight;
  12. @property (weak, nonatomic) IBOutlet UIView *spreadView;
  13. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *spreadViewHeight;
  14. @end
  15. @implementation MineBottomView
  16. - (void)awakeFromNib {
  17. [super awakeFromNib];
  18. self.isTestUser = YES;
  19. }
  20. + (instancetype)shareInstance {
  21. MineBottomView *view = [[[NSBundle mainBundle] loadNibNamed:@"MineBottomView" owner:nil options:nil] firstObject];
  22. return view;
  23. }
  24. - (void)operationCallback:(MineViewCallback)callback {
  25. if (callback) {
  26. self.callback = callback;
  27. }
  28. }
  29. - (CGFloat)getViewHeight {
  30. CGFloat defaultHeight = 484.0f;
  31. if (self.isMember == NO) {
  32. defaultHeight -= 60.0f;
  33. }
  34. if (self.isTestUser) {
  35. defaultHeight -= 60.0f;
  36. }
  37. CGFloat viewHeight = defaultHeight;
  38. return viewHeight;
  39. }
  40. - (void)setIsMember:(BOOL)isMember {
  41. _isMember = isMember;
  42. if (isMember) {
  43. self.tradeViewHeight.constant = 60.0f;
  44. self.tradeView.hidden = NO;
  45. }
  46. else{
  47. self.tradeViewHeight.constant = 0.0f;
  48. self.tradeView.hidden = YES;
  49. }
  50. }
  51. - (void)setIsTestUser:(BOOL)isTestUser {
  52. _isTestUser = isTestUser;
  53. if (isTestUser) {
  54. self.spreadView.hidden = YES;
  55. self.spreadViewHeight.constant = 0.0f;
  56. }
  57. else {
  58. self.spreadView.hidden = NO;
  59. self.spreadViewHeight.constant = 60.0f;
  60. }
  61. }
  62. - (IBAction)tapAction:(UITapGestureRecognizer *)sender {
  63. NSInteger index = sender.view.tag;
  64. if (self.callback) {
  65. self.callback(index);
  66. }
  67. }
  68. /*
  69. // Only override drawRect: if you perform custom drawing.
  70. // An empty implementation adversely affects performance during animation.
  71. - (void)drawRect:(CGRect)rect {
  72. // Drawing code
  73. }
  74. */
  75. @end