From 3c7bf96e9f842736d2e1edb7e8d904134fd3b592 Mon Sep 17 00:00:00 2001 From: Antonio Agudo Date: Mon, 23 Mar 2015 16:38:46 +0100 Subject: [PATCH] Added sizeThatFits method --- Pod/Classes/IPInsetLabel.m | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Pod/Classes/IPInsetLabel.m b/Pod/Classes/IPInsetLabel.m index ae99942..80db3ca 100644 --- a/Pod/Classes/IPInsetLabel.m +++ b/Pod/Classes/IPInsetLabel.m @@ -44,13 +44,6 @@ - (id)initWithFrame:(CGRect)aFrame { return self; } -- (CGSize)intrinsicContentSize -{ - CGSize contentSize = [super intrinsicContentSize]; - - return CGSizeMake(contentSize.width + _insets.left + _insets.right, - contentSize.height + _insets.top + _insets.bottom); -} #pragma mark - UILabel @@ -86,6 +79,13 @@ - (void)resizeHeightToFitText self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, frame.size.width, frame.size.height); } +- (CGSize)sizeThatFits:(CGSize)size { + CGFloat widthInsets = _insets.left+_insets.right; + CGFloat heightInsets = _insets.top+_insets.bottom; + CGSize resultSize = [super sizeThatFits:CGSizeMake(size.width- widthInsets, size.height- heightInsets)]; + return CGSizeMake(resultSize.width+widthInsets, resultSize.height+heightInsets); +} + #pragma mark - Private