![](/img/trans.png)
[英]Auto Layout: can't get the frame size of UICollectionViewCell subViews
[英]I can't animate UICollectionViewCell subclass or any of it's subviews
我有一個動畫功能,可以在應用程序的許多其他部分中使用它,並且效果很好:
class func pulse(view: UIView, sizeMultiplier: Float, duration: NSTimeInterval, repeatCount: Float = 1.0) {
let pulseAnimation = CABasicAnimation(keyPath: "transform.scale")
pulseAnimation.duration = duration
pulseAnimation.toValue = NSNumber(float: sizeMultiplier)
pulseAnimation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
pulseAnimation.autoreverses = true
pulseAnimation.repeatCount = repeatCount
view.layer.addAnimation(pulseAnimation, forKey: nil)
}
但是由於某種原因,我無法為UICollectionView
的單元設置動畫
在我的didSelectItemAtIndexPath
函數中(該函數正在調用,我使用斷點進行了檢查),具有以下功能:
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as! ModuleCell
Animations.pulse(cell, sizeMultiplier: 2.0, duration: 0.2, repeatCount: 2)
有任何想法嗎?
將您的代碼更改為
let cell = collectionView.cellForItemAtIndexPath(indexPath)
您當前正在創建/出隊新的單元格,而不是檢索當前的單元格。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.