I have a tableview
with custom cells which are built from storyboard
with an identifier using AutoLayout
.
One of the subviews
needs to be round (layer.cornerRadius = width/2)
, it is a square in the beginning.
I have tried in layoutSubviews()
but it seems to be called before AutoLayout
changes its size... same thing for didMoveToSuperview()
Where is the proper function to update things like this to my subviews after AutoLayout
has changed their sizes?
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("cell_small") as! Cell
...
return cell
}
// In Cell
override func layoutSubviews() {
rankLabel.layer.cornerRadius = rankLabel.bounds.width/2
rankLabel.layer.masksToBounds = true
}
override func didMoveToSuperview() {
rankLabel.layer.cornerRadius = rankLabel.bounds.width/2
rankLabel.layer.masksToBounds = true
}
Result: