Cell selection and animation

This commit is contained in:
Charles Magahern
2015-12-31 16:57:57 -08:00
parent df0f72af23
commit 303c620372
2 changed files with 71 additions and 15 deletions

View File

@@ -57,6 +57,11 @@ class SwitchesViewController: UIViewController,
{
let reuseID = SwitchesViewController.collectionViewCellReuseIdentifier
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseID, forIndexPath: indexPath) as! WemoDeviceCellView
var device = WemoDevice()
device.name = "beatmania IIDX"
cell.device = device
cell.ordinal = indexPath.row + 1
return cell
@@ -71,4 +76,10 @@ class SwitchesViewController: UIViewController,
let dimensions = rint(collectionView.bounds.size.width / cellsPerRow) - spacing
return CGSize(width: dimensions, height: dimensions)
}
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath)
{
let cell = collectionView.cellForItemAtIndexPath(indexPath) as! WemoDeviceCellView
cell.toggled = !cell.toggled
}
}