class SHomeViewController:UIViewController,UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout{
var collectionView : UICollectionView?
var dataArr = NSMutableArray()//数据源
var headerArr = NSMutableArray()//分组标题
let headerHeight:CGFloat = 30
let cellHeight:CGFloat = (SCREEN_WIDTH - 20)/3
let headerIdentifier:String = "headView"
func initView(){
let layout = UICollectionViewFlowLayout()
self.view.backgroundColor = UIColor.whiteColor()
layout.sectionInset = UIEdgeInsetsMake(5, 5, 5, 5);
layout.minimumInteritemSpacing = 5; // this number could be anything <=5. Need it here because the default is 10.
layout.minimumLineSpacing = 4.0 //设置行间距
layout.itemSize = CGSizeMake((SCREEN_WIDTH - 20)/3, (SCREEN_WIDTH - 20)/3) // 20 is 2*5 for the 2 edges plus 2*5 for the spaces between the cells
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as! SHomeCell
let title = dataArr[indexPath.row]
cell.titleLabel?.text = title as? String
return cell