Simplifies UIImageView
animations via set of classes and extensions.
- Copy content of
Source
folder to your project.
or
- Use
CirclePlayer
cocoapod
- iOS 9 and later
- Xcode 9 and later
- Swift 4
Let's assume, you have set of images in your Xcode project and you'd like to use them for playing animation within UIImageView
instance. How this could be done with normal UIKit
approach:
imageView.animationImages = [
UIImage(named: "image_1")!,
UIImage(named: "image_2")!,
UIImage(named: "image_3")!,
UIImage(named: "image_4")!,
UIImage(named: "image_5")!,
UIImage(named: "image_6")!,
UIImage(named: "image_7")!,
UIImage(named: "image_8")!,
// etc.
]
imageView.animationDuration = 1
imageView.animatedImageView.animationRepeatCount = 1000
imageView.animatedImageView.startAnimating()
With Circle
library you can implement the same behavior by using these lines:
imageView.crl
.prefix("image_")
.from(1)
.to(8)
.duration(1)
.repeatCount(1000)
.start()
If images are stored in another bundle, simply mention it by using bundle
method:
imageView.crl
.bundle(Bundle(identifier: "com.test.SomeBundle"))
.prefix("image_")
.from(1)
.to(180)
.duration(1)
.repeatCount(3)
.start()
All methods support call chains, so you can save reference to AnimationManager
object and use it to stop animation later:
let animationManager = imageView.crl
.prefix("image_")
.from(1)
.to(240)
.duration(4)
.repeatCount(1000)
.start()
animationManager.stop()
Circle
is available under the MIT license. See the LICENSE file for more info.