@interface TRCMallPaddingLabel : UILabel
@property (nonatomic, assign) UIEdgeInsets edgeInsets;
@end
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self.edgeInsets = UIEdgeInsetsMake(3, 0, 3, 0);
}
return self;
}
- (void)drawRect:(CGRect)rect {
[super drawTextInRect:UIEdgeInsetsInsetRect(rect, self.edgeInsets)];
}
- (CGSize)intrinsicContentSize {
CGSize size = [super intrinsicContentSize];
size.width+= self.edgeInsets.left + self.edgeInsets.right;
size.height+= self.edgeInsets.top + self.edgeInsets.bottom;
return size;
}