美文网首页UI
使UILabel文字居上,文字顶部对齐

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

作者: 里克尔梅西 | 来源:发表于2020-09-17 09:59 被阅读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

相关文章

网友评论

    本文标题:使UILabel文字居上,文字顶部对齐

    本文链接:https://www.haomeiwen.com/subject/mwxlyktx.html