ios - Change text color of UILabel inside Custom UICollectionViewCell -
i have been trying change text color of uilabel
inside custom cell in uicollectionview
. using following code allows me change background color of cell
need change text color:
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 clear color let celltodeselect:uicollectionviewcell = collectionview.cellforitematindexpath(indexpath)! celltodeselect.contentview.backgroundcolor = uicolor.clearcolor() }
i have seen few apps in hair line kind of thing keeps moving under selected cell. knows how implement well?
tia
if custom cell need add label custom uicollectionviewcell
import uikit class customcell: uicollectionviewcell { let label: uilabel! = nil }
then, in selectitematindexpath:
func collectionview(collectionview: uicollectionview, didselectitematindexpath indexpath: nsindexpath) { let selectedcell: customcell = collectionview.cellforitematindexpath(indexpath) as! customcell selectedcell.label.textcolor = uicolor(red: 102/256, green: 255/256, blue: 255/256, alpha: 0.66) }
Comments
Post a Comment