問題描述
單擊消息後的 MessageKit 動畫 (MessageKit animation after click on message)
我嘗試在我的應用程序中添加相同的動畫,我們可以在信使中找到,點擊一些消息後,應用程序顯示日期標籤。我可以顯示這個日期,但我不能添加流暢的動畫。我嘗試添加 uiview.animate(withDuration),但在我閱讀的另一個主題中,我需要調用方法 layoutIfNeed,但我無法處理來自 messagekit 的任何對象。有人可以幫助我,或者給我另一種方法來做這個滑動動畫
func didTapMessage(in cell: MessageCollectionViewCell) {
if isClicked {
isClicked = false
if let layout = messagesCollectionView.collectionViewLayout as? MessagesCollectionViewFlowLayout {
layout.setMessageOutgoingMessagePadding(UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0))
}
} else {
isClicked = true
if let layout = messagesCollectionView.collectionViewLayout as? MessagesCollectionViewFlowLayout {
UIView.animate(withDuration: 3) {
//MARK: how called layoufIfNeeded()? or how do this animation another way
layout.collectionView?.layoutIfNeeded()
layout.setMessageOutgoingMessagePadding(UIEdgeInsets(top: 10, left: 0, bottom: 0, right: 0))
}
}
}
let indexPath = self.messagesCollectionView.indexPath(for: cell)!
messagesCollectionView.reloadItems(at: [indexPath])
}