Created
September 28, 2014 07:37
-
-
Save sdpjswl/28429d11a93bc2a15736 to your computer and use it in GitHub Desktop.
UILabel category to add insets to text
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// SejoPaddingLabel.h | |
// GiftyOne | |
// | |
// Created by Esense-33 on 18/07/14. | |
// Copyright (c) 2014 GiftyOne. All rights reserved. | |
// | |
#import <UIKit/UIKit.h> | |
@interface SejoPaddingLabel : UILabel | |
@property (nonatomic, assign) UIEdgeInsets edgeInsets; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// SejoPaddingLabel.m | |
// GiftyOne | |
// | |
// Created by Esense-33 on 18/07/14. | |
// Copyright (c) 2014 GiftyOne. All rights reserved. | |
// | |
#import "SejoPaddingLabel.h" | |
@implementation SejoPaddingLabel | |
- (id)initWithFrame:(CGRect)frame | |
{ | |
self = [super initWithFrame:frame]; | |
if (self) | |
{ | |
self.edgeInsets = UIEdgeInsetsMake(0, 0.1, 0, 0.1); | |
} | |
return self; | |
} | |
- (void)drawTextInRect:(CGRect)rect | |
{ | |
[super drawTextInRect:UIEdgeInsetsInsetRect(rect, self.edgeInsets)]; | |
} | |
/* | |
// Only override drawRect: if you perform custom drawing. | |
// An empty implementation adversely affects performance during animation. | |
- (void)drawRect:(CGRect)rect | |
{ | |
// Drawing code | |
} | |
*/ | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment