I am trying to change colour for all numbers present in a string in swift
code.Example:
var mystring = \"abc 3423 opqrs 474598 lmno 343543\"
NSMutableAttributedString * string = [[NSMutableAttributedString alloc] initWithString:"Your Text"];
[string addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0,5)]; //give range where you want
[string addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(5,6)];//give range where you want
[string addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:NSMakeRange(11,5)]; //give range where you want
YourLable.attributedText = string;