JXVipDetailCenterView.m 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. //
  2. // JXVipDetailCenterView.m
  3. // shiku_im
  4. //
  5. // Created by cindy on 2020/6/3.
  6. // Copyright © 2020 Reese. All rights reserved.
  7. //
  8. #import "JXVipDetailCenterView.h"
  9. #import "XFStepView.h"
  10. #import "JXMyModel.h"
  11. #import "Common.h"
  12. @interface JXVipDetailCenterView ()<UIScrollViewDelegate>
  13. @end
  14. @implementation JXVipDetailCenterView
  15. - (instancetype)initWithFrame:(CGRect)frame Titles:(nonnull NSArray *)titles{
  16. if ([super initWithFrame:frame]){
  17. if (self) {
  18. self.clipsToBounds = NO;
  19. [self _addSubViews:titles];
  20. }
  21. }
  22. return self;
  23. }
  24. - (void)_addSubViews:(NSArray *)array {
  25. //等级ScrollView
  26. self.grapeScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 40)];
  27. self.grapeScrollView.contentSize = CGSizeMake(100*array.count, 40);
  28. self.grapeScrollView.bounces = NO;
  29. [self addSubview:self.grapeScrollView];
  30. //等级UI
  31. self.stepView = [[XFStepView alloc]initWithFrame:CGRectMake(0, 0, 100*array.count, 40) Titles:array];
  32. [self.grapeScrollView addSubview:self.stepView];
  33. self.pictureScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(50, self.grapeScrollView.bottom+10, kScreenWidth-100, 120)];
  34. self.pictureScrollView.delegate = self;
  35. self.pictureScrollView.clipsToBounds = NO;
  36. self.pictureScrollView.clipsToBounds = NO;
  37. self.pictureScrollView.pagingEnabled = YES;
  38. self.pictureScrollView.bounces = NO;
  39. self.pictureScrollView.showsHorizontalScrollIndicator = NO;
  40. self.pictureScrollView.contentSize = CGSizeMake(self.pictureScrollView.frame.size.width*array.count, 120);
  41. [self addSubview:self.pictureScrollView];
  42. //创建图片
  43. for(int i = 0; i <array.count;i++) {
  44. CGRect frame = self.pictureScrollView.frame;
  45. vipDetailModel *model=array[i];
  46. UIImageView *imageView = nil;
  47. if ([model.grade intValue]==0) {
  48. if (i==0) {
  49. imageView = [[UIImageView alloc]initWithFrame:CGRectMake(10, 0, self.pictureScrollView.width-20, 120)];
  50. }else{
  51. imageView = [[UIImageView alloc]initWithFrame:CGRectMake(frame.size.width * i + 10, 0, self.pictureScrollView.width-20, 120)];
  52. }
  53. }else{
  54. imageView = [[UIImageView alloc]initWithFrame:CGRectMake(frame.size.width * i + 10, 0, self.pictureScrollView.width-20, 120)];
  55. }
  56. imageView.tag = 200+i;
  57. imageView.layer.cornerRadius = 12;
  58. imageView.layer.masksToBounds = YES;
  59. imageView.backgroundColor = RGBColor(207, 194, 200);
  60. [self.pictureScrollView addSubview:imageView];
  61. UIImageView *vipImageView = [[UIImageView alloc] initWithFrame:CGRectMake(imageView.width-70, 0, 62, 74)];
  62. vipImageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"vip_icon_%d",i+1]];
  63. [imageView addSubview:vipImageView];
  64. UILabel *vipLabel = [[UILabel alloc] initWithFrame:CGRectMake(1, 29, vipImageView.width, 12)];
  65. vipLabel.text = @"VIP";
  66. vipLabel.textColor = [UIColor brownColor];
  67. vipLabel.textAlignment = NSTextAlignmentCenter;
  68. vipLabel.font = kBoldFont(7);
  69. [vipImageView addSubview:vipLabel];
  70. self.numberLabel = [[UILabel alloc] initWithFrame:CGRectMake(1, vipLabel.bottom, vipImageView.width, 11)];
  71. self.numberLabel.text =[NSString stringWithFormat:@"%@",model.grade];
  72. self.numberLabel.textColor = [UIColor brownColor];
  73. self.numberLabel.textAlignment = NSTextAlignmentCenter;
  74. self.numberLabel.font = kBoldFont(14);
  75. [vipImageView addSubview:self.numberLabel];
  76. UILabel *dengjiLabel = [[UILabel alloc] initWithFrame:CGRectMake(30, 30, 100, 20)];
  77. dengjiLabel.textColor = kWhiteColor;
  78. dengjiLabel.textAlignment = NSTextAlignmentLeft;
  79. dengjiLabel.font = kBoldFont(22);
  80. dengjiLabel.tag = 1000+i;
  81. dengjiLabel.text = model.name;
  82. [imageView addSubview:dengjiLabel];
  83. UILabel *leijiPriceLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, dengjiLabel.bottom+25, 90, 15)];
  84. leijiPriceLabel.textColor = kWhiteColor;
  85. leijiPriceLabel.textAlignment = NSTextAlignmentCenter;
  86. leijiPriceLabel.font = kFont(13);
  87. leijiPriceLabel.tag = 10000+i;
  88. leijiPriceLabel.text = [NSString stringWithFormat:@"%@",model.rechargeMoney];
  89. [imageView addSubview:leijiPriceLabel];
  90. UILabel *leijiLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, leijiPriceLabel.bottom+5, 90, 15)];
  91. leijiLabel.textColor = kWhiteColor;
  92. leijiLabel.textAlignment = NSTextAlignmentCenter;
  93. leijiLabel.font = kFont(13);
  94. leijiLabel.text = @"累计存款";
  95. [imageView addSubview:leijiLabel];
  96. }
  97. self.currentPageLabel = [[UILabel alloc] initWithFrame:CGRectMake(kScreenWidth-90, self.pictureScrollView.bottom+10, 30, 20)];
  98. self.currentPageLabel.text = @"1";
  99. self.currentPageLabel.textColor = [UIColor blackColor];
  100. self.currentPageLabel.textAlignment = NSTextAlignmentRight;
  101. self.currentPageLabel.font = [UIFont systemFontOfSize:14];
  102. [self addSubview:self.currentPageLabel];
  103. UILabel *totalPageLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.currentPageLabel.right, self.pictureScrollView.bottom+10, 30, 20)];
  104. totalPageLabel.text = [NSString stringWithFormat:@"/%zd",array.count];
  105. totalPageLabel.textColor = [UIColor purpleColor];
  106. totalPageLabel.textAlignment = NSTextAlignmentLeft;
  107. totalPageLabel.font = [UIFont systemFontOfSize:14];
  108. [self addSubview:totalPageLabel];
  109. }
  110. #pragma mark -UIScrollView delegate
  111. - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
  112. if(self.delegate && [self.delegate respondsToSelector:@selector(scrollViewDidEndDeceleratingWithCenterView:)]){
  113. [self.delegate scrollViewDidEndDeceleratingWithCenterView:scrollView];
  114. }
  115. }
  116. @end