我一直在嘗試更改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