ios - 如何在 Xamarin iOS 中为 UITableViewCell 从底部到顶部的过渡设置动画?
<p><p>如何在 Xamarin iOS 原生中为 UITableViewCell 从底部到顶部的过渡设置动画?</p>
<p>您好所有 Xamarin iOS 原生社区,我正在寻找一种方法来为 UITableView 中的 UITableViewCell 设置动画,为任何单元格创建从底部到顶部的过渡效果。</p>
<p> <a href="/image/RpbgY.gif" rel="noreferrer noopener nofollow"><img src="/image/RpbgY.gif" alt="enter image description here"/></a> </p>
<p>因为我找到的所有示例都在 Swift 中,所以我自己解决了这个答案,我将把解决方案分享给社区。</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>Swift 4 并修复滚动问题:</p>
<pre><code>private var finishedLoadingInitialTableCells = false
override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
var lastInitialDisplayableCell = false
//change flag as soon as last displayable cell is being loaded (which will mean table has initially loaded)
if favorites.itemes.count > 0 && !finishedLoadingInitialTableCells {
if let indexPathsForVisibleRows = tableView.indexPathsForVisibleRows,
let lastIndexPath = indexPathsForVisibleRows.last, lastIndexPath.row == indexPath.row {
lastInitialDisplayableCell = true
}
}
if !finishedLoadingInitialTableCells {
if lastInitialDisplayableCell {
finishedLoadingInitialTableCells = true
}
//animates the cell as it is being displayed for the first time
do {
let startFromHeight = tableView.frame.height
cell.layer.transform = CATransform3DMakeTranslation(0, startFromHeight, 0)
let delay = Double(indexPath.row) * 0.2
UIView.animate(withDuration: 0.7, delay: delay, options: UIViewAnimationOptions.transitionFlipFromBottom, animations: {
do {
cell.layer.transform = CATransform3DIdentity
}
}) { (success:Bool) in
}
}
}
}
</code></pre></p>
<p style="font-size: 20px;">关于ios - 如何在 Xamarin iOS 中为 UITableViewCell 从底部到顶部的过渡设置动画?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/46811043/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/46811043/
</a>
</p>
页:
[1]