如何在 Xamarin iOS 原生中为 UITableViewCell 从底部到顶部的过渡设置动画?
您好所有 Xamarin iOS 原生社区,我正在寻找一种方法来为 UITableView 中的 UITableViewCell 设置动画,为任何单元格创建从底部到顶部的过渡效果。
因为我找到的所有示例都在 Swift 中,所以我自己解决了这个答案,我将把解决方案分享给社区。p>
Swift 4 并修复滚动问题:
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
}
}
}
}
关于ios - 如何在 Xamarin iOS 中为 UITableViewCell 从底部到顶部的过渡设置动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46811043/
欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://jike.in/) | Powered by Discuz! X3.4 |