YichenBman
YichenBman

Reputation: 5661

Animated Image animationRepeatCount CollectionViewCell

I have a pretty neat animation that basically draws out a border for a collection view cell.

I have the animation working well, I'm unable to keep it from repeating indefinitely.

In: func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {

I have set up the cell this way:

var image = UIImage.animatedImageNamed("Shape + Oval ", duration: 0.5)

    cell.cellImageView.animationRepeatCount = 1
    cell.cellImageView.image = image

Why is animationRepeatCount not stopping my cell images from continually looping

Upvotes: 0

Views: 308

Answers (1)

Paulw11
Paulw11

Reputation: 114974

You have mixed two different methods of animating an image in a UIImageView - You are supplying an animated UIImage but then trying to control the animation via the UIImageView properties.

Rather than using an animated UIImage, you should create an array of UIImage objects and use this to set the animationImages property of the cell.imageView. You can then control the duration via cell.imageView.animationDuration and cell.imageView.animationRepeatCount

Upvotes: 1

Related Questions