UILabel使文字居上,文字顶部对齐

一个简单的小技巧,使的文字能够居上:

只要继承 UILabe,然后重写 drawTextInRect方法,如下:

- (void)drawTextInRect:(CGRect)rect {
    CGRect actualRect = [self textRectForBounds:rect 
                         limitedToNumberOfLines:self.numberOfLines];
    [super drawTextInRect:actualRect];
}

使用的时候只需要正常使用就好了~ (⁎⁍̴̛ᴗ⁍̴̛⁎)

你可能感兴趣的:(UILabel使文字居上,文字顶部对齐)