//
Collectionviewcontroller.swift
tab
//
Created by Su on 15/12/8.
Copyright©2015 year Tian. All rights reserved.
//
Import UIKit
Class Collectionviewcontroller:uiviewcontroller, Uicollectionviewdelegate, Uicollectionviewdatasource {
var collectionview:uicollectionview!
Override Func Viewdidload () {
Super.viewdidload ()
Let FlowLayout = Uicollectionviewflowlayout ()
Flowlayout.itemsize = cgsize (width: (Tools). SCREEN_WIDTH-30)/3, Height: (Tools (). SCREEN_WIDTH-30)/3)
CollectionView = Uicollectionview (Frame:self.view.bounds, Collectionviewlayout:flowlayout)
Collectionview.backgroundcolor = Uicolor.whitecolor ()
Collectionview.registernib (uinib (nibname: "Collectionviewcell", Bundle:nil), Forcellwithreuseidentifier: " Collectionviewcell ")
Collectionview.delegate = Self
Collectionview.datasource = Self
Self.view.addSubview (CollectionView)
}
Func CollectionView (Collectionview:uicollectionview, Numberofitemsinsection section:int), Int {
Return 10
}
Func CollectionView (Collectionview:uicollectionview, Cellforitematindexpath Indexpath:nsindexpath) Uicollectionviewcell {
Let cell = Collectionview.dequeuereusablecellwithreuseidentifier ("Collectionviewcell", Forindexpath:indexpath)
return cell
}
Override Func didreceivememorywarning () {
Super.didreceivememorywarning ()
Dispose of any resources the can be recreated.
}
/*
MARK:-Navigation
In a storyboard-based application, you'll often want to do a little preparation before navigation
Override Func Prepareforsegue (Segue:uistoryboardsegue, sender:anyobject?) {
Get The new view controller using Segue.destinationviewcontroller.
Pass the selected object to the new view controller.
}
*/
}
Swift creates Uicollectionview