Custom UITableViewCell corners distorted on orientation change (UACellBackgroundView)
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 c开发者_Go百科orners 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 = 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:
.
精彩评论