I need to use the iOS's system font "Hiragino Sans W3" in my app, but no matter which size/style or the UILabel
's dimensions I choose, the font's ascenders and descenders always appear clipped:
It seems that this can this fixed by creating a subclass of UILabel
and overwriting method textRectForBounds:limitedToNumberOfLines:
to return the "correct" value. So the following code...
- (CGRect)textRectForBounds:(CGRect)bounds limitedToNumberOfLines:(NSInteger)numberOfLines
{
CGRect result = [super textRectForBounds:bounds limitedToNumberOfLines:numberOfLines];
result = CGRectInset(result, 0, -5);
return result;
}
...results in both the ascender and descenders not being clipped anymore:
I know it's also possible to adjust font ascender and descender positions using an external editor. But this is a system font, shouldn't it work correctly without any modifications? Is there something I'm missing here?
Thanks in advance for any answers.