CNLiveHomePageDigitalRMBViewController.m 5.09 KB
//
//  CNLiveHomePageDigitalRMBViewController.m
//  CNLiveDigitalRMBHomeDeom
//
//  Created by daojian on 2023/4/26.
//

#import "CNLiveHomePageDigitalRMBViewController.h"
#import "NewPagedFlowView.h"
#import "CNLiveDigitalRMBHelp.h"

#import<CNLiveCommonCategory/UIColor+CNLiveExtension.h>
#import<YYCategories/YYCategories.h>

#define Width [UIScreen mainScreen].bounds.size.width
#define Height [UIScreen mainScreen].bounds.size.height

@interface CNLiveHomePageDigitalRMBViewController ()

/**
 *  图片数组
 */
@property (nonatomic, strong) NSMutableArray *dataArray;

@property (nonatomic, strong) NewPagedFlowView *pageFlowView;
@end

@implementation CNLiveHomePageDigitalRMBViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    for (int index = 0; index < 2; index++) {
        [self.dataArray addObject:@""];
    }
    [self setupUI];
    
//    let  maskPath = UIBezierPath.init(roundedRect: box, byRoundingCorners: [.topRight,.topLeft], cornerRadii: CGSizeMake(width: 6.0, height: 6.0))
//
//    let maskLayer = CAShapeLayer()
//
//    maskLayer.frame = self.bgView.bounds
//
//    maskLayer.path = maskPath.cgPath
//
//    self.bgView.layer.mask = maskLayer
    
    
   
    
//    CGFloat W = Width-100;
//    UIView *topView = [[UIView alloc] initWithFrame:CGRectMake(50, 0, W,W/2)];
//    topView.backgroundColor = [UIColor clearColor];
//    [self.view addSubview:topView];
//
//    //画半圆
//    UIBezierPath *circle = [UIBezierPath bezierPathWithArcCenter:CGPointMake(W/2, 0) radius:W/2 startAngle:0 endAngle:M_PI clockwise:YES];
//    CAShapeLayer *shapeLayer = [[CAShapeLayer alloc] init];
//    shapeLayer.path = circle.CGPath;
//    shapeLayer.fillColor = [UIColor greenColor].CGColor;
//    [topView.layer addSublayer:shapeLayer];
//
//    UIView *bottomView = [[UIView alloc] initWithFrame:CGRectMake(50, Height -W/2 , W,W/2)];
//    bottomView.backgroundColor = [UIColor clearColor];
//    [self.view addSubview:bottomView];
//
//    UIBezierPath *bottomCircle = [UIBezierPath bezierPathWithArcCenter:CGPointMake(W/2, W/2) radius:W/2 startAngle:0 endAngle:M_PI clockwise:NO];
//    CAShapeLayer *bottomShapeLayer = [[CAShapeLayer alloc] init];
//    bottomShapeLayer.path = bottomCircle.CGPath;
//    bottomShapeLayer.fillColor = [UIColor greenColor].CGColor;
//    [bottomView.layer addSublayer:bottomShapeLayer];
//
//    UILabel *laber =[[UILabel alloc] initWithFrame:CGRectMake(100, 50, 100, 20)];
//    laber.text = @"付钱";
//    laber.textAlignment = NSTextAlignmentCenter;
//    [bottomView addSubview:laber];
    
}
#pragma mark --push控制器
- (void)pushCustomVC {

    
}

- (void)setupUI {
    
    self.automaticallyAdjustsScrollViewInsets = NO;
    
//    NewPagedFlowView *pageFlowView = [[NewPagedFlowView alloc] initWithFrame:CGRectMake(0, 72, Width, Width * 9 / 16)];
    NewPagedFlowView *pageFlowView = [[NewPagedFlowView alloc] initWithFrame:CGRectMake(0, 0, Width, Height)];

    pageFlowView.delegate = self;
    pageFlowView.dataSource = self;
    pageFlowView.minimumPageAlpha = 0.1;
    pageFlowView.isCarousel = NO;
    pageFlowView.orientation = NewPagedFlowViewOrientationHorizontal;
    pageFlowView.leftRightMargin = 20;
    pageFlowView.isOpenAutoScroll = YES;
    
    //左右图片的距离顶部和底部的高度
    pageFlowView.topBottomMargin = 0;
    
    
    [pageFlowView reloadData];
    
    self.pageFlowView = pageFlowView;
    [self.view addSubview:pageFlowView];
    

}


#pragma mark NewPagedFlowView Delegate
- (void)didSelectCell:(UIView *)subView withSubViewIndex:(NSInteger)subIndex {
    
    NSLog(@"点击了第%ld张图",(long)subIndex + 1);
    
}

- (void)didScrollToPage:(NSInteger)pageNumber inFlowView:(NewPagedFlowView *)flowView {
    
    NSLog(@"ViewController 滚动到了第%ld页",pageNumber);
}

#pragma mark NewPagedFlowView Datasource
- (NSInteger)numberOfPagesInFlowView:(NewPagedFlowView *)flowView {
    
    return self.dataArray.count;
    
}

- (PGIndexBannerSubiew *)flowView:(NewPagedFlowView *)flowView cellForPageAtIndex:(NSInteger)index{
    PGIndexBannerSubiew *bannerView = [flowView dequeueReusableCell];
    if (!bannerView) {
        bannerView = [[PGIndexBannerSubiew alloc] initWithFrame:CGRectMake(0, 0, Width-50, Height)];
        bannerView.tag = index + 100;
        bannerView.layer.cornerRadius = 4;
        bannerView.layer.masksToBounds = NO;
    }
    bannerView.superScrollView = flowView.scrollView;
    bannerView.associatedVCView = self.view;
    return bannerView;
    
    
}

- (CGSize)sizeForPageInFlowView:(NewPagedFlowView *)flowView {
    return CGSizeMake(Width-50,Height);
}
#pragma mark --懒加载
- (NSMutableArray *)dataArray {
    if (_dataArray == nil) {
        _dataArray = [NSMutableArray array];
    }
    return _dataArray;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end