我一直在尝试更改UICollectionView
中自定义单元格内的UILabel
的文本颜色。目前我使用下面的代码,让我改变Cell
的背景颜色,但我只需要改变文字颜色:更改自定义UICollectionViewCell中UILabel的文本颜色
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
非常感谢。这正是我需要的:) – Molly
不客气。如果这有帮助,请选择它作为答案和upvote。 – Nate4436271