Created
July 24, 2015 09:05
-
-
Save mlabraca/303f3cd1e1704376df70 to your computer and use it in GitHub Desktop.
Returns an attributed string from value, custom gliph and given font
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
+ (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