UICollectionView的用法
来源:互联网 发布:如何做网络销售技巧 编辑:程序博客网 时间:2024/05/21 14:57
UICollectionView的用法 供以后使用
#import "CoverCollectionViewController.h"#import "CoverCollectionViewCell.h"@interface CoverCollectionViewController () <UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout>@property (nonatomic,strong)UICollectionView *collectionView;@end@implementation CoverCollectionViewControllerstatic NSString * const reuseIdentifier = @"Cell";- (void)viewDidLoad { [super viewDidLoad]; UIImageView *bg = [initUiTools initImageViewWithImageName:@"fish_bg" cornerRadius:0.0f]; [self.view addSubview:bg]; bg.frame = CGRectMake(0, -64, kUIScreenWidth, kUIScreenHeight); CGFloat itemW = (kUIScreenWidth - 40) / 3; UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; layout.sectionInset = UIEdgeInsetsMake(5, 10, 5, 10); layout.itemSize = CGSizeMake(itemW, itemW); // 每一个网格的尺寸 layout.minimumLineSpacing = 10; // 每一行之间的间距 self.collectionView.backgroundColor = [UIColor whiteColor]; self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, kUIScreenWidth, kUIScreenHeight - 64) collectionViewLayout:layout]; self.collectionView.delegate = self; self.collectionView.dataSource = self; self.collectionView.alwaysBounceVertical = YES; [self.view addSubview:self.collectionView]; // Register cell classes [self.collectionView registerClass:[CoverCollectionViewCell class] forCellWithReuseIdentifier:reuseIdentifier]; }- (void)viewDidAppear:(BOOL)animated{ [super viewDidAppear:animated]; self.view.backgroundColor = [UIColor clearColor]; self.collectionView.backgroundColor = [UIColor clearColor];}- (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.}*/#pragma mark <UICollectionViewDataSource>- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { return 1;}- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return 30;}- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { CoverCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath]; cell.backgroundColor = [UIColor redColor]; return cell;}
0 0
- ios UICollectionView 的用法
- UICollectionView的基本用法
- UICollectionView的基本用法
- UICollectionView的用法
- UICollectionView的用法小结
- UICollectionView的基础用法
- iOS UICollectionView的用法
- UICollectionView的基础用法
- [Swift 开发] UICollectionView的用法
- UICollectionView的更深层次的用法
- UICollectionView和自定义UICollectionViewCell的基本用法
- UICollectionView 高级用法
- UICollectionView 基本用法
- UICollectionView用法总结
- iOS-UICollectionView用法
- iOS求生之路(四)UICollectionView的用法
- UICollectionView用法补充(照片轮播墙)
- IOS6- UICollectionView的使用
- Filter应用之全站禁用浏览器缓存
- 项目记录05--客unity,服erlang--另外一种AssetBundle打包方式
- Linux文件系统基本目录结构概述
- Excel2013制作甘特图
- sip信令常用的响应码
- UICollectionView的用法
- sip信令常用的响应码
- Oracle EBS R12实用配置文件列表
- sip信令常用的响应码
- Git工作流指南:Pull Request工作流
- android原生系统老系统不支持localstorage
- 最近比较忙,昨天和今天在安装autocad,还是没装成功
- C++学习中关于cout遇到的一个小问题
- 黑马程序员 JavaSE-07 常用类