zoukankan      html  css  js  c++  java
  • IOS 瀑布流

    #import "ViewController.h"

    @interface ViewController ()<UICollectionViewDataSource,UICollectionViewDelegate>

    @end

    @implementation ViewController

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

    {

        UICollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];

        

        

        cell.backgroundColor=[UIColor colorWithRed:arc4random()%11/10.0 green:arc4random()%11/10.0 blue:arc4random()%11/10.0 alpha:1];

        return cell;

    }

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

    {

        return 25;

    }

    - (void)viewDidLoad {

        UICollectionViewFlowLayout *layout=[[UICollectionViewFlowLayout alloc]init];

        

        layout.scrollDirection=UICollectionViewScrollDirectionHorizontal;

        layout.itemSize=CGSizeMake(30, 30);

        

        

        

        UICollectionView *cv=[[UICollectionView alloc]initWithFrame:CGRectMake(0, 100, 375, 200) collectionViewLayout:layout];

        cv.delegate=self;

        cv.dataSource=self;

        [cv registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"cell"];

        [self.view addSubview:cv];

        

        [super viewDidLoad];

        // Do any additional setup after loading the view, typically from a nib.

    }

  • 相关阅读:
    查看文件的首尾行
    快捷键
    lua中奇葩用法
    lua中特殊用法
    CVPR2015一些文章整理
    hdu5371 最长回文子串变形(Manacher算法)
    SVN合并(merge)的使用
    atitit. 集合groupby 的实现(2)---自己定义linq查询--java .net php
    王立平--SQLite,SQLiteOpenHelper的简单应用
    Vim 经常使用快捷键及键盘图
  • 原文地址:https://www.cnblogs.com/linximu/p/4402628.html
Copyright © 2011-2022 走看看