Created
December 7, 2014 02:29
-
-
Save aclissold/75a50d4a05907b73dcf5 to your computer and use it in GitHub Desktop.
For github.com/Keithbsmiley/swift.vim/pull/30
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: NHBalancedFlowLayoutDelegate | |
func collectionView(collectionView: UICollectionView!, | |
layout collectionViewLayout: NHBalancedFlowLayout!, | |
preferredSizeForItemAtIndexPath indexPath: NSIndexPath!) -> CGSize { | |
if UIScreen.mainScreen().scale == 1.0 { | |
var size = photos[indexPath.item].size | |
size.width /= 2 | |
size.height /= 2 | |
return size | |
} | |
return photos[indexPath.item].size | |
} | |
// MARK: UICollectionViewDataSource | |
override func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int { | |
return 1 | |
} | |
override func collectionView(collectionView: UICollectionView, | |
numberOfItemsInSection section: Int) -> Int { | |
return photos.count | |
} | |
override func collectionView(collectionView: UICollectionView, | |
cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { | |
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(photoCellID, | |
forIndexPath: indexPath) as PhotoCell | |
if let highResPhoto = highResPhotos[indexPath.item] { | |
cell.imageButton.setBackgroundImage(highResPhoto, forState: .Normal) | |
} else { | |
cell.imageButton.setBackgroundImage(photos[indexPath.item], forState: .Normal) | |
} | |
cell.imageButton.tag = indexPath.item | |
return cell | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: NHBalancedFlowLayoutDelegate | |
func collectionView(collectionView: UICollectionView!, | |
layout collectionViewLayout: NHBalancedFlowLayout!, | |
preferredSizeForItemAtIndexPath indexPath: NSIndexPath!) -> CGSize { | |
if UIScreen.mainScreen().scale == 1.0 { | |
var size = photos[indexPath.item].size | |
size.width /= 2 | |
size.height /= 2 | |
return size | |
} | |
return photos[indexPath.item].size | |
} | |
// MARK: UICollectionViewDataSource | |
override func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int { | |
return 1 | |
} | |
override func collectionView(collectionView: UICollectionView, | |
numberOfItemsInSection section: Int) -> Int { | |
return photos.count | |
} | |
override func collectionView(collectionView: UICollectionView, | |
cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { | |
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(photoCellID, | |
forIndexPath: indexPath) as PhotoCell | |
if let highResPhoto = highResPhotos[indexPath.item] { | |
cell.imageButton.setBackgroundImage(highResPhoto, forState: .Normal) | |
} else { | |
cell.imageButton.setBackgroundImage(photos[indexPath.item], forState: .Normal) | |
} | |
cell.imageButton.tag = indexPath.item | |
return cell | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment