For some strange reason, in iPhone OS 3.0 this doesn't work: I made a big fullscreen UILabel with numberOfLines = 0
and baselineAdjustment = UIBaselineAdjustmentNone
.
It refuses to show the text in the upper left. It's always in the center of the bounding box, aligned to the left.
The documentation says:
UIBaselineAdjustmentNone Adjust text relative to the top-left corner of the bounding box. This is the default adjustment. Available in iPhone OS 2.0 and later.
Probably a framework bug? I started with shiny new labels to test it. Text is centered.
The default implementation vertically centers text and does not honor the contentMode
property. Implement drawTextInRect:
in a subclass.
@implementation TopLeftLabel
-(void) drawTextInRect:(CGRect)inFrame {
CGRect draw = [self textRectForBounds:inFrame limitedToNumberOfLines:[self numberOfLines]];
draw.origin = CGPointZero;
[super drawTextInRect:draw];
}
@end
The baselineAdjustment
property is strictly for when the font size is being adjusted to fit the width.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With