如何在NSKutableAttributedString期间使用动画更改背景颜色?

时间:2017-10-31 07:15:08

标签: uiview core-animation nsattributedstring

我想用动画改变文字的背景颜色。是否有任何方法可以将NSAttributedStringKey.backgroundColor设置为持续时间? 我的意思是Hello my dear friend , how are you ? 我想将friend的背景颜色改为黄色,用2s(秒)

1 个答案:

答案 0 :(得分:0)

除非您只想更改NSAttributedString

的一部分

您是否尝试过(Swift 3)以下内容?

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

适用于整个标签......