2015-08-16 29 views
0

我有我的應用程序的其他許多地方使用動畫功能,它完美的作品:我不能動畫UICollectionViewCell子類或任何它的子視圖

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) 

任何想法?

回答

1

更改您的代碼以

let cell = collectionView.cellForItemAtIndexPath(indexPath) 

您目前創建/出隊新的細胞,而不是獲取當前單元格。

+0

非常感謝你!!!!! – shakked

+0

@shakked歡迎您,很高興幫助! – luk2302