我正在從UITextView
添加和刪除屬性文本。我希望使用UIView.animate
爲文本添加到文本視圖時以及從文本視圖中刪除附加文本時添加動畫。到目前爲止,我有這個,但它不會導致對文本視圖任何明顯的動畫:iOS/Swift:使用UIView.animate爲從UITextView添加/刪除的文本添加動畫
UIView.animate(withDuration: 1, delay: 0, options: .CurveLinear, animations: {
self.view.layoutIfNeeded()
self.textView.attributedText = newAttributedText
}, completion: { finished in
print("Animation completed")
}
// prints "Animation completed", but no animation occurs
你能發佈你在哪裏使用這種代碼嗎? –
使用簡單的'UIView'動畫''屬性文字'(和'文本')屬性是不可動畫的。 – rmaddy