Reputation: 14327
For performance reasons (inside my subclassed UITableViewCell
), I'm experimenting with drawing text directly with drawRect
, rather than adding UILabel
subviews.
And in order for the text to be redrawn upon orientation change, I've set the view's contentMode
to UIViewContentModeRedraw
:
- (id)initWithFrame(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self setContentMode:UIViewContentModeRedraw];
}
return self;
}
- (void)drawRect:(CGRect)rect
{
[@"foo" drawInRect:CGRectInset(rect, 10, 10)
withFont:[UIFont systemFontOfSize:14]
lineBreakMode:NSLineBreakByWordWrapping];
}
Scrolling is much faster now, and it all works perfectly – almost.
The problem is: while the view is animating its interface-orientation rotation animation, the text appears warped/stretched. It looks great before and after the orientation, but wonky during the animation.
Is there any way to prevent the view from stretching, and basically imitate the way that UILabels behave when the interface is rotated?
Upvotes: 1
Views: 273
Reputation: 66292
Try UIViewContentModeTopLeft
. That's how I solved it in an identical situation in my app. This will prevent scaling. (See https://stackoverflow.com/a/3456973/1445366).
Upvotes: 2