0
点赞
收藏
分享

微信扫一扫

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

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

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

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

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

举报

相关推荐

0 条评论