Hi I'm using this code to try and make the text resize though I can't seen to get the label to resize. Also the init method in the custom class is not being called. Here is my code:
class Cell: UICollectionViewCell {
@IBOutlet weak var label: UILabel!
override init(frame: CGRect) {
super.init(frame: frame)
print("init—>Not being called???\n")
self.label.adjustsFontSizeToFitWidth = true
self.cell.label.sizeToFit()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
}
What can I do to get the init to call so. I have also tried adjusting the text in the method
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath
Though the text size of the label is not changing, Here's what the cell looks like with a longs string. Thanks in advance for your help.
If I place -
adjustsFontSizeToFitWidth
or
sizeToFit
:
into ->
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.label.adjustsFontSizeToFitWidth = true // causes error
self.label.sizeToFit()
}
I also get an error.