代码例子:http://pan.baidu.com/s/1bn06eOf http://download.csdn.net/detail/qqmcy/6887385
Cell.h
#import <UIKit/UIKit.h>
@interface Cell : UICollectionViewCell
@property (strong, nonatomic) UILabel* label;
@end
Cell.m
//
// Cell.m
// CollectionViewDemo1
//
// Created by 杜甲 on 14-1-26.
// Copyright (c) 2014年 杜甲. All rights reserved.
//
#import "Cell.h"
@implementation Cell
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
self.contentView.frame = CGRectMake(0, 0, 50, 15);
self.label = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 0.0, 50.0, 15)];
self.label.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
self.label.textAlignment = NSTextAlignmentCenter;
self.label.font = [UIFont boldSystemFontOfSize:15];
self.label.textColor = [UIColor colorWithRed:181.0 / 255.0 green:181.0 / 255.0 blue:181.0 / 255.0 alpha:1];
[self.contentView addSubview:self.label];
}
return self;
}
@end
LineLayout.h
#import <UIKit/UIKit.h>
@interface LineLayout : UICollectionViewFlowLayout
@end
LineLayout.m
#import "LineLayout.h"
#define ITEM_SIZE 20
@implementation LineLayout