【发布时间】:2016-08-24 03:45:31
【问题描述】:
我一直在尝试更改UICollectionView 中自定义单元格内UILabel 的文本颜色。目前我正在使用以下代码,它允许我更改 Cell 的背景颜色,但我只需要更改文本颜色:
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath)
{
//Change background color of selected Cell
let selectedCell:UICollectionViewCell = collectionView.cellForItemAtIndexPath(indexPath)!
selectedCell.contentView.backgroundColor = UIColor(red: 102/256, green: 255/256, blue: 255/256, alpha: 0.66)
}
func collectionView(collectionView: UICollectionView, didDeselectItemAtIndexPath indexPath: NSIndexPath)
{
//Set background color of selected Cell to Clear Color
let cellToDeselect:UICollectionViewCell = collectionView.cellForItemAtIndexPath(indexPath)!
cellToDeselect.contentView.backgroundColor = UIColor.clearColor()
}
我见过很少的应用程序在选定的单元格下不断移动细线之类的东西。任何人都知道如何实现它?
TIA
【问题讨论】:
标签: ios swift uicollectionview uilabel uicollectionviewcell