I want to animate a subview of a custom TableViewCell. To perform this animation, the cell needs the width of this subview, which is laid out by an auto-layout-constraint.
However, when I use the animation-function in the cellForRowAtIndex function (mycell.animate()
), the width is 0
, because the subviews are not laid out yet and the animation will not work.
In a regular view, I would use viewDidLayoutSubviews()
, because then the view is laid out, I can get the width and perform the animation. However, what's the equivalent function for a custom UITableViewCell?
I tried the willDisplay
delegate function of the TableView, but when I print out the width of the cells subview, it still says 0
...
cellForRow:at:
?cell.frame.size.width = tableView.frame.size.width
– BlowbyblowlayoutSubviews
inside the cell subclass might do the trick. – Scull