Skip to content

Instantly share code, notes, and snippets.

@mlabraca
Created July 24, 2015 09:05
Show Gist options
  • Save mlabraca/303f3cd1e1704376df70 to your computer and use it in GitHub Desktop.
Save mlabraca/303f3cd1e1704376df70 to your computer and use it in GitHub Desktop.
Returns an attributed string from value, custom gliph and given font
+ (NSMutableAttributedString *) getAttributtedStringFromValue:(NSString *)value andGliph:(NSString *)gliph forCustomFont:(NSString *)customFont
{
float fontSizeGliph = 25;
float fontSize = 20;
NSString *titleText = [NSString stringWithFormat:@"%@ %@", value, gliph];
UIFont *gliphFont = [UIFont fontWithName:customFont size:fontSizeGliph];
UIFont *defaultFont = [UIFont systemFontOfSize:fontSize];
NSMutableAttributedString *attributedTextMain = [[NSMutableAttributedString alloc] initWithString:titleText attributes:@{NSFontAttributeName:defaultFont}];
NSRange rangeTextGliph = [titleText rangeOfString:gliph];
[attributedTextMain setAttributes:@{NSFontAttributeName:gliphFont} range:rangeTextGliph];
return attributedTextMain;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment