swift - cellTopLabel background color and cornerRadius -


i want make rounded corner , background color celltoplabel, have used code:

override func collectionview(collectionview: uicollectionview, cellforitematindexpath indexpath: nsindexpath) -> uicollectionviewcell {     let cell = super.collectionview(collectionview, cellforitematindexpath: indexpath) as! jsqmessagescollectionviewcell      cell.celltoplabel?.backgroundcolor = uicolor.whitecolor()     cell.celltoplabel?.layer.cornerradius = 5     cell.celltoplabel?.bounds = cgrect(x: 0, y: 0, width: cell.celltoplabel!.bounds.width/4, height: 20)      return cell } 

but obtain result:

enter image description here

i don't want celltoplabel entire screen width, width needed, how can fix this?

your code seemed work me check have ✅ autoresizes subviews checked in properties inspector on messages view.


Comments