views:

23

answers:

1

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.)

+2  A: 

Set backgroundView.contentMode = UIViewContentModeRedraw if you want it to redraw when the bounds change.

Additionally, do not override -isOpaque like the example suggests; I'm pretty sure that opaque-ness is backed by the CALayer property of the same name. Instead, set self.opaque = NO in initWithFrame:.

tc.
Setting the backgroundView.contentMode to UIViewContentModeRedraw fixed it. Thank you! I tried not overriding -isOpaque and adding self.opaque = NO in initWithStyle (not using initWithFrame)... but that gave me black corners on the cell. Will play around with that some more.
Jawboxer
That's odd; I haven't had problems with setting opaqueness before (but maybe table cells are weird?).
tc.