I have a UIView in which I need to draw text in drawRect:
- (void)drawRect:(CGRect)rect {
...
[@"some text" drawAtPoint:somePoint withFont:someFont];
...
}
Since the text requires special formatting, I cannot just use UILabel.
It looks great until I rotate the device. Then the size of my custom UIView is resized (in the parent view method layoutSubviews), and the text is stretched in one direction and compressed in the other.
When I replace my view with UILabel, the text always looks great even when changing the borders of the view.
How can I get an idea of the same behavior as UILabel?
Some things that I learned but have not yet been successful:
- Set the required display level of DisplayOnBoundsChange to YES.
- contentStretch CGRectZero.
- setNeedsDisplay layoutSubviews.
, . - ?
: , contentMode UIViewContentModeRedraw, . . /, , / . UILabel.