I have a view, which is essentially a library of books, and I'm trying to add a circular loading animation to books so that the user can see the download progress when they select new books. The problem I am facing is that the loading animation works fine when it is in a cell in indexPath 0-0, but when it is in any other indexPath, the animation will flicker and appear instantly on other cells.
In the image below, I'm loading Japanese, but the bootloader temporarily breaks out on Albanian, Armenian, Cebuano and several other books that were not captured at the time of this screenshot. Since the Japanese bootloader also flickers, the moment I took the screenshot did not show the Japanese bootloader at all.

After some debugging, I found that this most likely happens because every time the view gets a reboot, the cells are reused, and for some reason the order of the cells changes cyclically. I tried to override prepareForReusein the user cell and reset the settings back to hidden, but I still get the ghost of progress for a split second, which causes a flicker.
. ,
func setupProgressCircle(){
progressCircle = CAShapeLayer();
let centerPoint = CGPoint (x: bookView.bounds.width / 2, y: bookView.bounds.height / 2);
let circleRadius : CGFloat = bookView.bounds.width / 2 * 0.5;
var circlePath = UIBezierPath(arcCenter: centerPoint, radius: circleRadius, startAngle: CGFloat(-0.5 * M_PI), endAngle: CGFloat(1.5 * M_PI), clockwise: true );
progressCircle = CAShapeLayer ();
progressCircle!.path = circlePath.CGPath;
progressCircle!.strokeColor = UIColor.whiteColor().CGColor;
progressCircle!.fillColor = UIColor.clearColor().CGColor;
progressCircle!.lineWidth = 5;
progressCircle!.strokeStart = 0;
progressCircle!.strokeEnd = 0
overlayView.layer.addSublayer(progressCircle);
}
cellForRowAtIndexPath, , .
func setProgress(progress: CGFloat){
progressCircle?.strokeEnd = progress
}
, , .
override func prepareForReuse() {
if progressCircle != nil{
progressCircle?.hidden = true
progressCircle!.strokeEnd = 0
}
}
, , , . collectionView.reloadData(), , , .
, . . !
UPDATE
, cellForRowAtIndexPath
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("CollectionCell", forIndexPath: indexPath) as! LanguageBookCell
var book = controller.objectAtIndexPath(indexPath) as! BookData
...Cell Text/Image/Config...
if(book.active == false){
cell.overlayView!.alpha = 0.7
cell.dlLabel.hidden = false
cell.dlLabel.text = "Tap to Download"
cell.progressCircle.hidden = true
}else if(book.status == "Loading"){
cell.progressCircle.hidden = false
cell.setProgress(percentLoaded)
}
... Other Cell Configs...
return cell
}