Skip to content

Instantly share code, notes, and snippets.

@funkydevil
Created August 19, 2015 07:07
Show Gist options
  • Save funkydevil/ac90b913d03698674ef3 to your computer and use it in GitHub Desktop.
Save funkydevil/ac90b913d03698674ef3 to your computer and use it in GitHub Desktop.
UILabel with paddings
//
// Created by Kirill Pyulzyu on 19.08.15.
// Copyright (c) 2015 Kirill Pyulzyu. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface UILabelWithInsets : UILabel
@property (nonatomic) CGFloat topInset;
@property (nonatomic) CGFloat leftInset;
@property (nonatomic) CGFloat bottomInset;
@property (nonatomic) CGFloat rightInset;
@end
//
// Created by Kirill Pyulzyu on 19.08.15.
// Copyright (c) 2015 Kirill Pyulzyu. All rights reserved.
//
#import "UILabelWithInsets.h"
@implementation UILabelWithInsets
{
}
- (void)drawTextInRect:(CGRect)rect
{
UIEdgeInsets insets = {self.topInset, self.leftInset,
self.bottomInset, self.rightInset};
return [super drawTextInRect:UIEdgeInsetsInsetRect(rect, insets)];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment