Created
March 24, 2014 05:13
-
-
Save liyong03/9734479 to your computer and use it in GitHub Desktop.
Revisions
-
liyong03 created this gist
Mar 24, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,57 @@ static const int kUnknownTextColor = 0x666663; static const CGFloat kUnknownFontSize = 14; static const CGFloat kUnknownLabelMargin = 20; @interface SocialUnknownLabel : UILabel + (CGFloat)requiredHeightWith:(CGFloat)width; @end @implementation SocialUnknownLabel + (CGFloat) requiredHeightWith:(CGFloat)width { width -= 2*kUnknownLabelMargin; CGSize size = [UNKNOWN_TXT sizeWithFont:HelNeueFontOfSize(kUnknownFontSize) constrainedToSize:CGSizeMake(width, 9999) lineBreakMode:NSLineBreakByWordWrapping]; return ceilf(size.height) + 2*kUnknownLabelMargin; } - (id) init { self = [super init]; if (self) { [self setup]; } return self; } - (id) initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self setup]; } return self; } - (void) setup { self.lineBreakMode = NSLineBreakByWordWrapping; self.numberOfLines = 0; self.textColor = UIColorFromRGB(kUnknownTextColor); self.font = HelNeueFontOfSize(kUnknownFontSize); self.text = UNKNOWN_TXT; } - (void) drawTextInRect:(CGRect)rect { UIEdgeInsets insets = {kUnknownLabelMargin, kUnknownLabelMargin, kUnknownLabelMargin, kUnknownLabelMargin}; [super drawTextInRect:UIEdgeInsetsInsetRect(rect, insets)]; } @end