I’m trying out this nice way of customizing grouped UITableViewCell backgrounds:
http://code.coneybeare.net/how-to-make-custom-drawn-gradient-backgrounds
I’ve implemented it in a test app and it works great, except for one thing… when rotating the device, the cell background is stretched, making the corners look distorted.
Is there any way to force a table cell to redraw itself on an orientation change? Do I need to use setNeedsDisplay somewhere?
(I’ve tried [cell.backgroundView setNeedsDisplay] in a couple of places just as a random guess… but that didn’t work.)
Set
backgroundView.contentMode = UIViewContentModeRedrawif you want it to redraw when the bounds change.Additionally, do not override
-isOpaquelike the example suggests; I’m pretty sure that opaque-ness is backed by the CALayer property of the same name. Instead, setself.opaque = NOininitWithFrame:.