gpt4 book ai didi

ios - 如何在 Xamarin iOS 中为 UITableViewCell 从底部到顶部的过渡设置动画?

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:36:31 24 4
gpt4 key购买 nike

如何在 Xamarin iOS 原生中为 UITableViewCell 从底部到顶部的过渡设置动画?

大家好 Xamarin iOS native 社区,我正在寻找一种方法来为 UITableView 中的 UITableViewCell 设置动画,创建从底部到顶部的过渡,并为任何单元格提供淡入淡出效果。

enter image description here

因为我找到的所有示例都是用 Swift 编写的,所以我自己解决了这个问题,我将把解决方案分享给社区。

最佳答案

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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com