This repository has been archived by the owner on May 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
John Hsu
authored and
John Hsu
committed
May 27, 2013
1 parent
807d245
commit c4886fd
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// UILabel+JOExtension.h | ||
// | ||
// Copyright (c) 2012. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface UILabel (JOExtension) | ||
// Creates transparent UILabel object with specified properties | ||
// Default is text color is black, font is system default | ||
// You should call sizeToFit manually | ||
+(UILabel *)labelWithText:(NSString *)text; | ||
+(UILabel *)labelWithText:(NSString *)text color:(UIColor *)color; | ||
+(UILabel *)labelWithText:(NSString *)text font:(UIFont *)font; | ||
+(UILabel *)labelWithText:(NSString *)text color:(UIColor *)color font:(UIFont *)font; | ||
@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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// UILabel+JOExtension.m | ||
// | ||
// Copyright (c) 2012. All rights reserved. | ||
// | ||
|
||
#import "UILabel+JOExtension.h" | ||
|
||
@implementation UILabel (JOExtension) | ||
+(UILabel *)labelWithText:(NSString *)text | ||
{ | ||
return [self labelWithText:text color:nil font:nil]; | ||
} | ||
|
||
+(UILabel *)labelWithText:(NSString *)text color:(UIColor *)color | ||
{ | ||
return [self labelWithText:text color:color font:nil]; | ||
|
||
} | ||
|
||
+(UILabel *)labelWithText:(NSString *)text font:(UIFont *)font | ||
{ | ||
return [self labelWithText:text color:nil font:font]; | ||
} | ||
|
||
+(UILabel *)labelWithText:(NSString *)text color:(UIColor *)color font:(UIFont *)font | ||
{ | ||
UILabel *label = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease]; | ||
label.backgroundColor = [UIColor clearColor]; | ||
if (font) { | ||
label.font = font; | ||
} | ||
if (color) { | ||
label.textColor = color; | ||
} | ||
label.text = text; | ||
return label; | ||
} | ||
|
||
@end |