Skip to content

Instantly share code, notes, and snippets.

@ritesh-fueled
Last active August 29, 2015 13:56
Show Gist options
  • Save ritesh-fueled/9107730 to your computer and use it in GitHub Desktop.
Save ritesh-fueled/9107730 to your computer and use it in GitHub Desktop.
Attributed String
NSMutableAttributedString *attributedString =
[[NSMutableAttributedString alloc]initWithString:@"someText"];
NSDictionary *defaultProperties = @{ NSFontAttributeName : [UIFont defaultFont],
NSForegroundColorAttributeName : [UIColor defaultColor]};
NSDictionary *uniqueProperty = @{ NSFontAttributeName : [UIFont uniqueFont],
NSForegroundColorAttributeName : [UIColor uniqueColor]};
[attributedString addAttributes:defaultProperties
range:NSMakeRange(defaultStartLocationInIntegers,
defaultEndLocationInIntegers)];
[attributedString addAttributes:uniqueProperty
range:NSMakeRange(uniqueStartLocationInIntegers,
uniqueEndLocationInIntegers];
// to insert character spacing
/*
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:text];
[attributedString addAttribute:NSKernAttributeName
value:@(characterSpacing)
range:NSMakeRange(0, [text length])];
self.attributedText = attributedString;
*/
[self.someLabel setAttributedText:attributedString];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment