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

阅读 58

2021-09-22

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

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

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

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

相关推荐

精彩评论(0)

0 0 举报