gpt4 book ai didi

ios - 使用 Facebook Pop 对 View 仿射变换进行动画处理

转载 作者:行者123 更新时间:2023-11-28 07:11:52 25 4
gpt4 key购买 nike

我有以下代码,将以 Spring 方式从底部为一些 UITableViewCell 设置动画:

override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
self.tableView.reloadData()

let cellsNum = self.tableView.visibleCells() as NSArray

// Hide the tableView and move the cells to below the tableView
self.tableView.alpha = 0.0
for cell in cellsNum as [UITableViewCell] {
cell.transform = CGAffineTransformMakeTranslation(0, self.tableView.bounds.size.height)
println("\(NSStringFromCGAffineTransform(cell.transform))")
//cell.layer.transform = CATransform3DRotate(CATransform3DIdentity, CGFloat(90.0) * CGFloat(M_PI) / CGFloat(180.0), 1.0, 0.0, 0.0)
}

// Show the tableView and animate the cells
self.tableView.alpha = 1.0
for cell in cellsNum as [UITableViewCell] {
UIView.animateWithDuration(1.2, delay: 0.05 * Double(cellsNum.indexOfObject(cell)), usingSpringWithDamping: 0.77, initialSpringVelocity: 0, options: nil, animations: { () -> Void in
cell.transform = CGAffineTransformMakeTranslation(0, 0)
//cell.layer.transform = CATransform3DRotate(CATransform3DIdentity, 0, 1.0, 0.0, 0.0)
}, completion: nil);
}
}

我如何在 Facebook Pop 中执行此操作?我查看了源代码,但最接近的是 kPopLayerTranslationXY,但下面的代码不起作用:

for cell in cellsNum as [UITableViewCell] {
let trans = POPSpringAnimation(propertyNamed: kPOPLayerTranslationXY)
trans.toValue = NSValue(CGPoint: CGPointMake(0, 0))
trans.fromValue = NSValue(CGPoint: CGPointMake(0, self.tableView.bounds.size.height))
trans.springBounciness = 10
trans.springSpeed = 5
cell.pop_addAnimation(trans, forKey: "Translation")
}

可能定义自定义动画属性?

最佳答案

您正在为图层属性设置动画,因此您应该将动画添加到单元格的图层,而不是单元格。

cell.layer.pop_addAnimation(trans, forKey: "Translation")

此外,由于您只为 y 设置动画,因此您可以使用 kPOPLayerTranslationY 并将 toValuefromValue 设置为 float 。

关于ios - 使用 Facebook Pop 对 View 仿射变换进行动画处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28161310/

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