Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Tunde Adegoroye
20,597 PointsDynamically change width of label based on text
So basically i'm developing a project in swift and i want to change the size of a label based on the text content within the array below.
private let cellItems = ["All", "Design", "Development", "Social"]
Each label is within a collectionviewcell and this is where i am creating the cells and setting their text content.
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell: colvwCell = collectionView.dequeueReusableCellWithReuseIdentifier("newsCell", forIndexPath: indexPath) as! colvwCell
cell.typeLbl.text = cellItems[indexPath.row]
// Stuck here
return cell;
}
But this is where i am stuck since i'm unsure on what to do next can anyone offer any help or advice on how to achieve this.