123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- //
- // JXVipDetailCenterView.m
- // shiku_im
- //
- // Created by cindy on 2020/6/3.
- // Copyright © 2020 Reese. All rights reserved.
- //
- #import "JXVipDetailCenterView.h"
- #import "XFStepView.h"
- #import "JXMyModel.h"
- #import "Common.h"
- @interface JXVipDetailCenterView ()<UIScrollViewDelegate>
- @end
- @implementation JXVipDetailCenterView
- - (instancetype)initWithFrame:(CGRect)frame Titles:(nonnull NSArray *)titles{
- if ([super initWithFrame:frame]){
- if (self) {
- self.clipsToBounds = NO;
- [self _addSubViews:titles];
- }
- }
- return self;
- }
- - (void)_addSubViews:(NSArray *)array {
- //等级ScrollView
- self.grapeScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 40)];
- self.grapeScrollView.contentSize = CGSizeMake(100*array.count, 40);
- self.grapeScrollView.bounces = NO;
- [self addSubview:self.grapeScrollView];
-
- //等级UI
- self.stepView = [[XFStepView alloc]initWithFrame:CGRectMake(0, 0, 100*array.count, 40) Titles:array];
- [self.grapeScrollView addSubview:self.stepView];
- self.pictureScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(50, self.grapeScrollView.bottom+10, kScreenWidth-100, 120)];
- self.pictureScrollView.delegate = self;
- self.pictureScrollView.clipsToBounds = NO;
- self.pictureScrollView.clipsToBounds = NO;
- self.pictureScrollView.pagingEnabled = YES;
- self.pictureScrollView.bounces = NO;
- self.pictureScrollView.showsHorizontalScrollIndicator = NO;
- self.pictureScrollView.contentSize = CGSizeMake(self.pictureScrollView.frame.size.width*array.count, 120);
- [self addSubview:self.pictureScrollView];
- //创建图片
- for(int i = 0; i <array.count;i++) {
- CGRect frame = self.pictureScrollView.frame;
- vipDetailModel *model=array[i];
- UIImageView *imageView = nil;
- if ([model.grade intValue]==0) {
- if (i==0) {
- imageView = [[UIImageView alloc]initWithFrame:CGRectMake(10, 0, self.pictureScrollView.width-20, 120)];
- }else{
- imageView = [[UIImageView alloc]initWithFrame:CGRectMake(frame.size.width * i + 10, 0, self.pictureScrollView.width-20, 120)];
- }
-
- }else{
- imageView = [[UIImageView alloc]initWithFrame:CGRectMake(frame.size.width * i + 10, 0, self.pictureScrollView.width-20, 120)];
- }
- imageView.tag = 200+i;
- imageView.layer.cornerRadius = 12;
- imageView.layer.masksToBounds = YES;
- imageView.backgroundColor = RGBColor(207, 194, 200);
- [self.pictureScrollView addSubview:imageView];
-
- UIImageView *vipImageView = [[UIImageView alloc] initWithFrame:CGRectMake(imageView.width-70, 0, 62, 74)];
- vipImageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"vip_icon_%d",i+1]];
- [imageView addSubview:vipImageView];
-
- UILabel *vipLabel = [[UILabel alloc] initWithFrame:CGRectMake(1, 29, vipImageView.width, 12)];
- vipLabel.text = @"VIP";
- vipLabel.textColor = [UIColor brownColor];
- vipLabel.textAlignment = NSTextAlignmentCenter;
- vipLabel.font = kBoldFont(7);
- [vipImageView addSubview:vipLabel];
-
- self.numberLabel = [[UILabel alloc] initWithFrame:CGRectMake(1, vipLabel.bottom, vipImageView.width, 11)];
- self.numberLabel.text =[NSString stringWithFormat:@"%@",model.grade];
- self.numberLabel.textColor = [UIColor brownColor];
- self.numberLabel.textAlignment = NSTextAlignmentCenter;
- self.numberLabel.font = kBoldFont(14);
- [vipImageView addSubview:self.numberLabel];
-
- UILabel *dengjiLabel = [[UILabel alloc] initWithFrame:CGRectMake(30, 30, 100, 20)];
- dengjiLabel.textColor = kWhiteColor;
- dengjiLabel.textAlignment = NSTextAlignmentLeft;
- dengjiLabel.font = kBoldFont(22);
- dengjiLabel.tag = 1000+i;
- dengjiLabel.text = model.name;
- [imageView addSubview:dengjiLabel];
-
- UILabel *leijiPriceLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, dengjiLabel.bottom+25, 90, 15)];
- leijiPriceLabel.textColor = kWhiteColor;
- leijiPriceLabel.textAlignment = NSTextAlignmentCenter;
- leijiPriceLabel.font = kFont(13);
- leijiPriceLabel.tag = 10000+i;
- leijiPriceLabel.text = [NSString stringWithFormat:@"%@",model.rechargeMoney];
- [imageView addSubview:leijiPriceLabel];
- UILabel *leijiLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, leijiPriceLabel.bottom+5, 90, 15)];
- leijiLabel.textColor = kWhiteColor;
- leijiLabel.textAlignment = NSTextAlignmentCenter;
- leijiLabel.font = kFont(13);
- leijiLabel.text = @"累计存款";
- [imageView addSubview:leijiLabel];
- }
-
- self.currentPageLabel = [[UILabel alloc] initWithFrame:CGRectMake(kScreenWidth-90, self.pictureScrollView.bottom+10, 30, 20)];
- self.currentPageLabel.text = @"1";
- self.currentPageLabel.textColor = [UIColor blackColor];
- self.currentPageLabel.textAlignment = NSTextAlignmentRight;
- self.currentPageLabel.font = [UIFont systemFontOfSize:14];
- [self addSubview:self.currentPageLabel];
- UILabel *totalPageLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.currentPageLabel.right, self.pictureScrollView.bottom+10, 30, 20)];
- totalPageLabel.text = [NSString stringWithFormat:@"/%zd",array.count];
- totalPageLabel.textColor = [UIColor purpleColor];
- totalPageLabel.textAlignment = NSTextAlignmentLeft;
- totalPageLabel.font = [UIFont systemFontOfSize:14];
- [self addSubview:totalPageLabel];
-
-
- }
- #pragma mark -UIScrollView delegate
- - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
-
- if(self.delegate && [self.delegate respondsToSelector:@selector(scrollViewDidEndDeceleratingWithCenterView:)]){
- [self.delegate scrollViewDidEndDeceleratingWithCenterView:scrollView];
- }
- }
- @end
|