Skip to content

Instantly share code, notes, and snippets.

@sdpjswl
Created September 28, 2014 07:37
Show Gist options
  • Save sdpjswl/28429d11a93bc2a15736 to your computer and use it in GitHub Desktop.
Save sdpjswl/28429d11a93bc2a15736 to your computer and use it in GitHub Desktop.
UILabel category to add insets to text
//
// 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
//
// 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