0

I want to change background color of text with animation. Does any way exist to set NSAttributedStringKey.backgroundColor with duration time? I mean in Hello my dear friend , how are you ? I want to change the background color of friend to yellow color with 2s (second)

rmaddy
  • 307,833
  • 40
  • 508
  • 550
AzAli
  • 1
  • 3

1 Answers1

0

Unless you want to change only part of the NSAttributedString

Did you try (Swift 3) the following?

UIView.animate(withDuration: 0.3) {
     label.backgroundColor = .red
}

That works for the whole label...

DanielH
  • 645
  • 4
  • 6
  • I don't want change background color for all characters , I want to change only some characters , for instance change bgColor for char 0 to 5 – AzAli Oct 31 '17 at 09:18