主要是重载label的:-(void) drawTextInRect:(CGRect)rect ;
@implementation ZXJLabel{
UIEdgeInsets _insets;
}
-(instancetype)initWithInsets:(UIEdgeInsets)insets
{
if (self = [super init]) {
_insets = insets;
}
return self;
}
#pragma mark - 主要是重写该方法
-(void)drawTextInRect:(CGRect)rect
{
return [super drawTextInRect:UIEdgeInsetsInsetRect(rect, _insets)];
}
github: https://github.com/qianxunaimama/ToolsAndLogs/commits/master