I want to change color to all characters in string. But my code is giving just last character in string. I want to append characters in attributed string. How can I do this ?
My Code :
func test(){
var str:String = "test string"
for i in 0...count(str)-1{
var test = str[advance(str.startIndex, i)]
var attrString = NSAttributedString(string: toString(test), attributes: [NSForegroundColorAttributeName: rainbowColors()])
label.attributedText = attrString
}
}