GuiZuViewController.m 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. //
  2. // GuiZuViewController.m
  3. // BuguLive
  4. //
  5. // Created by bugu on 2019/12/2.
  6. // Copyright © 2019 xfg. All rights reserved.
  7. //
  8. #import "GuiZuViewController.h"
  9. #import "GuiZuView.h"
  10. #import "GuiZuBottomView.h"
  11. @interface GuiZuViewController ()
  12. @property(nonatomic, strong) NSMutableArray *dataArray;
  13. @property(nonatomic, strong) UIScrollView *mainScrollView;
  14. @property(nonatomic, strong) UIScrollView *titleScrollView;
  15. @property(nonatomic, strong) UIView *titlesView;
  16. @property(nonatomic, assign) NSInteger type;
  17. @property(nonatomic, strong) GuiZuView *guiZuView;
  18. @property(nonatomic, strong) GuiZuBottomView *bottomView;
  19. @end
  20. @implementation GuiZuViewController
  21. - (void)viewDidLoad {
  22. [super viewDidLoad];
  23. [self backBtnWithBlock];
  24. // Do any additional setup after loading the view.
  25. }
  26. - (void)backBtnWithBlock
  27. {
  28. // 返回按钮
  29. [self setupBackBtnWithBlock:nil];
  30. }
  31. - (void)initFWUI{
  32. [super initFWUI];
  33. [self.view addSubview:self.mainScrollView];
  34. [self.view addSubview:self.bottomView];
  35. [self.mainScrollView addSubview:self.guiZuView];
  36. [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
  37. make.left.right.mas_equalTo(0);
  38. make.bottom.mas_equalTo(isIPhoneX()?-34 :0);
  39. make.height.mas_equalTo(70);
  40. }];
  41. self.guiZuView.frame = CGRectMake(0, 0, kScreenW, kRealValue(550));
  42. [self.mainScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
  43. make.left.top.right.mas_equalTo(0);
  44. make.bottom.equalTo(self.bottomView.mas_top).offset(-20);
  45. }];
  46. [self.view addSubview:self.titlesView];
  47. }
  48. -(void)initFWData
  49. {
  50. [super initFWData];
  51. [self.bottomView setDataWithGift:@"333" money:@"3" day:@"33"];
  52. }
  53. #pragma mark 主页和直播的点击事件
  54. - (void)HLBtnClick:(UIButton *)btn
  55. {
  56. [self updateUIWithTag:(int)btn.tag];
  57. }
  58. - (void)updateUIWithTag:(int)tag
  59. {
  60. for (UIButton *newBtn in self.titlesView.subviews)
  61. {
  62. if ([newBtn isKindOfClass:[UIButton class]])
  63. {
  64. if (newBtn.tag ==tag)
  65. {
  66. [newBtn setTitleColor:[UIColor colorWithHexString:@"#FFEF77"] forState:UIControlStateNormal];
  67. newBtn.titleLabel.font = [UIFont boldSystemFontOfSize:16];
  68. }else
  69. {
  70. [newBtn setTitleColor:[UIColor colorWithHexString:@"#E5E5E5"] forState:UIControlStateNormal];
  71. newBtn.titleLabel.font = [UIFont systemFontOfSize:14];
  72. }
  73. }
  74. }
  75. //页面刷新
  76. // [_myScrollView scrollRectToVisible:CGRectMake(tag * kScreenW, 0, kScreenW, CGRectGetHeight(_myScrollView.frame)) animated:YES];
  77. }
  78. #pragma mark - setter
  79. - (NSMutableArray *)dataArray{
  80. if (!_dataArray) {
  81. _dataArray = [NSMutableArray array];
  82. }
  83. return _dataArray;
  84. }
  85. - (UIScrollView *)mainScrollView{
  86. if (!_mainScrollView) {
  87. _mainScrollView = ({
  88. UIScrollView * scrollView = [[UIScrollView alloc]init];
  89. // scrollView.contentSize = CGSizeMake(kScreenW, kScreenH);
  90. scrollView;
  91. });
  92. }
  93. return _mainScrollView;
  94. }
  95. - (GuiZuView *)guiZuView{
  96. if (!_guiZuView) {
  97. _guiZuView = [[GuiZuView alloc]init];;
  98. }
  99. return _guiZuView;
  100. }
  101. - (GuiZuBottomView *)bottomView{
  102. if (!_bottomView) {
  103. _bottomView = [[GuiZuBottomView alloc]init];
  104. }
  105. return _bottomView;
  106. }
  107. - (UIView *)titlesView{
  108. if (!_titlesView) {
  109. _titlesView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 45*kAppRowHScale)];
  110. _titlesView.backgroundColor = [UIColor clearColor];
  111. NSArray *nameArray = @[ASLocalizedString(@"玄铁"),ASLocalizedString(@"青铜"),ASLocalizedString(@"白银"),ASLocalizedString(@"黄金"),ASLocalizedString(@"铂金"),ASLocalizedString(@"钻石"),ASLocalizedString(@"星耀"),ASLocalizedString(@"王者")];
  112. CGFloat btnWidth = kScreenW/nameArray.count;
  113. for (int i = 0; i < nameArray.count; i ++)
  114. {
  115. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  116. button.frame = CGRectMake(btnWidth*i ,0,btnWidth, 49);
  117. [button setTitle:nameArray[i] forState:0];
  118. button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
  119. if (self.type == i)
  120. {
  121. [button setTitleColor:[UIColor colorWithHexString:@"#FFEF77"] forState:UIControlStateNormal];
  122. button.titleLabel.font = [UIFont boldSystemFontOfSize:16];
  123. }else
  124. {
  125. [button setTitleColor:[UIColor colorWithHexString:@"#E5E5E5"] forState:UIControlStateNormal];
  126. button.titleLabel.font = [UIFont systemFontOfSize:14];
  127. }
  128. button.tag = i;
  129. [button addTarget:self action:@selector(HLBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  130. [_titlesView addSubview:button];
  131. }
  132. }
  133. return _titlesView;
  134. }
  135. @end