Skip to content

Commit

Permalink
Add standard way to get font out of NUISettings.
Browse files Browse the repository at this point in the history
  • Loading branch information
phatmann committed Feb 3, 2014
1 parent 7bcdd5d commit f0216eb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions NUI/Core/NUISettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
+ (UIEdgeInsets)getEdgeInsets:(NSString*)property withClass:(NSString*)className;
+ (UITextBorderStyle)getBorderStyle:(NSString*)property withClass:(NSString*)className;
+ (UITableViewCellSeparatorStyle)getSeparatorStyle:(NSString*)property withClass:(NSString*)className;
+ (UIFont*)getFontWithClass:(NSString*)className;
+ (UIColor*)getColor:(NSString*)property withClass:(NSString*)className;
+ (UIColor*)getColorFromImage:(NSString*)property withClass:(NSString*)className;
+ (UIImage*)getImage:(NSString*)property withClass:(NSString*)className;
Expand Down
26 changes: 26 additions & 0 deletions NUI/Core/NUISettings.m
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,32 @@ + (UITableViewCellSeparatorStyle)getSeparatorStyle:(NSString*)property withClass
return [NUIConverter toSeparatorStyle:[self get:property withClass:className]];
}

+ (UIFont*)getFontWithClass:(NSString*)className
{
NSString *propertyName;
CGFloat fontSize;
UIFont *font = nil;

propertyName = @"font-size";

if ([self hasProperty:propertyName withClass:className]) {
fontSize = [self getFloat:@"font-size" withClass:className];
} else {
fontSize = [UIFont systemFontSize];
}

propertyName = @"font-name";

if ([self hasProperty:propertyName withClass:className]) {
NSString *fontName = [self get:propertyName withClass:className];
font = [UIFont fontWithName:fontName size:fontSize];
} else {
font = [UIFont systemFontOfSize:fontSize];
}

return font;
}

+ (UIColor*)getColor:(NSString*)property withClass:(NSString*)className
{
return [NUIConverter toColor:[self get:property withClass:className]];
Expand Down

0 comments on commit f0216eb

Please sign in to comment.