• videoTypes


    //

    //  VideoTypesController.m

    //  Patient

    //

    //  Created by gzz on 16/11/10.

    //  Copyright © 2016 ShangYu. All rights reserved.

    //

     

    #import "VideoTypesController.h"

    #import "MyHeaderView.h"

    #import "MyFooterView.h"

    @interface VideoTypesController ()<UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout>

     

    @property(strong,nonatomic)UICollectionView *myCollectionV;

    @end

    static NSString *indentifyVideoTypes = @"indentifyVideoTypes";

     

    @implementation VideoTypesController

     

    - (void)viewDidLoad {

        [super viewDidLoad];

        self.view.backgroundColor = [UIColor lightGrayColor];

        self.title = @"专家讲座";

        [self navBarVideotypes];

        [self dataOpenstypes];

        [self makeUIVideotypes];

    }

     

     

    #pragma mark 数据的初始化

    -(void)dataOpenstypes{

        

    }

    -(void)makeUIVideotypes{

        UICollectionViewFlowLayout *flowL = [UICollectionViewFlowLayout new];

        flowL.minimumInteritemSpacing = 0;

        flowL.minimumLineSpacing = 0;

        [flowL setScrollDirection:UICollectionViewScrollDirectionVertical];

        

        

        _myCollectionV = [[UICollectionView alloc]initWithFrame:CGRectMake (10, 0SCREEN_WIDTH-20,SCREEN_HEIGHT) collectionViewLayout:flowL];

        _myCollectionV.delegate =self;

        _myCollectionV.dataSource =self;

        _myCollectionV.backgroundColor = RGB(188, 188, 188);//[UIColor yellowColor];

        _myCollectionV.showsVerticalScrollIndicator = NO;

        [self.view addSubview:_myCollectionV];

        

    #pragma mark -- 注册单元格

        [_myCollectionV registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:indentifyVideoTypes];

    #pragma mark -- 注册头部视图

        [_myCollectionV registerClass:[MyHeaderView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"HeaderView"];

    #pragma mark -- 注册尾部视图

        [_myCollectionV registerClass:[MyFooterView class] forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"FooterView"];

    }

     

     

    #pragma mark --UICollectionView dataSource

    //有多少个Section

    - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView

    {

        return 2;

    }

     

    //每个section有多少个元素

    - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section

    {

        if (section == 0) {

            return 0;

      

        }else{

            return 11;

     

        

        }

        

       

    }

    //每个单元格的数据

    - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath

    {

        

        

        UICollectionViewCell *cell = (UICollectionViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:indentifyVideoTypes forIndexPath:indexPath];

        for (UIView *view in cell.contentView.subviews) {

            [view removeFromSuperview];

        }

        cell.backgroundColor = [UIColor purpleColor];

        //    [cell sizeToFit];gzz1110

        [cell.contentView addSubview:[self cellIndex:(int)indexPath.item]];

        return cell;

    }

     

     

    #pragma mark 自定义item

    -(UIView *)cellIndex:(NSInteger)index{

        

        CGFloat widthD = (SCREEN_WIDTH-30)/2;

        CGFloat height = widthD/1.61;

        

        UIView  *viewdd = [[UIView alloc]initWithFrame:CGRectMake(1, 1, widthD-2, height-2)];

        viewdd.backgroundColor = [UIColor whiteColor];

        

        UIImageView *imageViews = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, widthD-2, height-2)];

        imageViews.backgroundColor = [UIColor redColor];

        [viewdd addSubview:imageViews];

        

        UILabel *desLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(imageViews.frame)+10, widthD-2, 10)];

        desLabel.textColor = [UIColor blackColor];

        desLabel.numberOfLines=2;

        desLabel.font = [UIFont systemFontOfSize:16];

        [viewdd addSubview:desLabel];

        //    NSString *summary=[newsLIST objectForKey:@"title"];

        desLabel.text=@"大家看法的;快乐亲耳朵是否答复是积极电视剧解决的加减法";

        if (index == 2) {

            desLabel.text=@"大加减法dd答复顶顶顶顶份";

        }

        if (index == 1) {

            desLabel.text=@"大答复顶顶顶顶份";

        }

        [desLabel sizeToFit];

        

        

        UILabel *expertLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(imageViews.frame)+10+36+10, 80, 16)];

        expertLabel.textAlignment = NSTextAlignmentLeft;

        expertLabel.textColor = [UIColor lightGrayColor];

        expertLabel.font = [UIFont systemFontOfSize:14];

        expertLabel.text = @"张德来专家";

        [viewdd addSubview:expertLabel];

        expertLabel.backgroundColor = [UIColor yellowColor];

        

        

        UIView *liangView = [[UIView alloc]initWithFrame:CGRectMake(widthD-50, 12, 40, 16)];

        liangView.backgroundColor = [UIColor redColor];

        liangView.centerY = expertLabel.centerY;

        [viewdd addSubview:liangView];

        

        

        NSString *nums = @"123";

        UIImageView *image1 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 18, 16)];

        image1.backgroundColor = [UIColor purpleColor];

        [liangView addSubview:image1];

        

        UILabel *label2 = [[UILabel alloc]init];

        label2.frame = CGRectMake(CGRectGetMaxY(image1.frame)+5, 2, 30, 16);

        [liangView addSubview:label2];

        label2.font = [UIFont systemFontOfSize:12];

        label2.text = nums;

        label2.backgroundColor = [UIColor purpleColor];

        [label2 sizeToFit];

        label2.centerY = image1.centerY;

        

        CGFloat liangX = widthD-image1.width-label2.width-15;

        

        liangView.frame = CGRectMake(liangX, liangView.y, image1.width+label2.width+5, liangView.height);

        

        

        expertLabel.frame = CGRectMake(expertLabel.x, expertLabel.y, liangX-5, expertLabel.height);

        

        

        viewdd.frame = CGRectMake(viewdd.frame.origin.x, viewdd.frame.origin.y, viewdd.frame.size.width, CGRectGetMaxY(expertLabel.frame)+10);

        return viewdd;

    }

     

    //每个cell的大小

    - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath

    {

        

        CGFloat widthD = (SCREEN_WIDTH-30)/2;

        //    CGFloat height = widthD/1.61+36+30+16+16;

        CGFloat height = widthD/1.61+36+30+16;

        return CGSizeMake(widthD, height);

    }

     

     

     

     

    //点击单元格

    -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath

    {

        MCLog(@"------nsectio---%ld/.item....%ld",indexPath.section,indexPath.item);

    }

     

    -(CGSize)collectionView:(UICollectionView*)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section

    {

       

        return CGSizeMake(self.view.frame.size.width, 0.1);

        

    }

     

    - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section{

        

        return CGSizeMake(self.view.frame.size.width, 10);

        

    }

     

    ////距边界缩放大小

    -(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section

    {

        return UIEdgeInsetsMake(0, 0 , 0, 0);//分别为上、左、下、右

        

    }

     

     

     

     

     

     

     

     

     

     

     

    #pragma mark navbar及返回

    -(void)navBarVideotypes{

        UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"gdback3"] originalImage] style:UIBarButtonItemStylePlain target:self action:@selector(backClickVideotype)];

        self.navigationItem.leftBarButtonItem=backItem;

        self.navigationController.interactivePopGestureRecognizer.delegate = nil;

    }

     

    -(void)backClickVideotype{

        [self.navigationController popViewControllerAnimated:YES];

    }

     

     

     

     

     

    - (void)didReceiveMemoryWarning {

        [super didReceiveMemoryWarning];

        // Dispose of any resources that can be recreated.

    }

     

    /*

    #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

  • 相关阅读:
    15分钟学会使用Git和远程代码库
    关注的一些个人博客记录
    vue实现筛选功能,文字选中变色
    为博客添加二次元人物方法
    收藏几个用的到的网站
    《代码整洁之道》学习记录
    《架构整洁之道》学习记录
    《指尖上行--移动前端开发进阶之路》学习记录
    《JavaScript设计模式》学习记录
    《以匠心,致设计》学习记录
  • 原文地址:https://www.cnblogs.com/gzz2016/p/6050669.html
Copyright © 2020-2023  润新知