使UILabel文字居上,文字顶部对齐
2020-09-17 本文已影响0人
里克尔梅西
继承UI�Label,写一个TopLabel完成这个小功能
#import "TopLabel.h"
@implementation TopLabel
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code
}
*/
- (void)drawTextInRect:(CGRect)rect {
CGRect actualRect = [self textRectForBounds:rect
limitedToNumberOfLines:self.numberOfLines];
[super drawTextInRect:actualRect];
}
@end