I'm looking for a way to change color in UIRefreshControl
.
The text is shown in an NSAttributedString
, so I try to use CoreText.framework
:
NSString *s = @"Hello";
NSMutableAttributedString *a = [[NSMutableAttributedString alloc] initWithString:s];
[a addAttribute:(id)kCTForegroundColorAttributeName value:(id)[UIColor redColor].CGColor range:NSRangeFromString(s)];
refreshControl.attributedTitle = a;
The text is shown correctly, but the color is always the default gray. Any ideas ?
You should be using NSForegroundColorAttributeName
, not kCTForegroundColorAttributeName
.
Also, the range being passed should be NSMakeRange(0, [s length]);
.