I am trying to size my UICollectionViewCell for the proper size of a given label, and I also want to add some padding so the label doesn't look suffocated. This is my class I'm using for the CollectionViewCell:
class BarTypeCell: UICollectionViewCell {
@IBOutlet weak var nameLabel: SizeToFit!
override func awakeFromNib() {
self.frame = CGRect(x: self.frame.origin.x, y: self.frame.origin.y, width: self.nameLabel.frame.width + 10, height: self.nameLabel.frame.height + 10)
self.layer.borderColor = UIColor.label.cgColor
self.layer.borderWidth = 1.0
self.layer.cornerRadius = 5.0
self.clipsToBounds = true
}
}
and this is what the output looks like:
How can I give the cell labels proper padding from the border?