Swiftpack.co -  GodL/Animatable as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
GodL/Animatable
A simpler way to set coreAnimation with PropertyWrapper.
.package(url: "https://github.com/GodL/Animatable.git", from: "1.0.6")

Animatable

✨ A simpler way to set coreAnimation with PropertyWrapper.

At a Glance

Initialize animations.

    enum Animations {
        struct TranslationAnimation: AnimatedType {
            var animation: CAAnimation {
                let animation = CABasicAnimation(keyPath: "transform.translation.x")
                animation.duration = 2
                animation.toValue = 200
                return animation
            }
        }

        struct ScaleAnimation: AnimatedType {
            var animation: CAAnimation {
                let animation = CABasicAnimation(keyPath: "transform.scale")
                animation.duration = 2
                animation.toValue = 2
                return animation
                }
            }
        }

Use animations with PropertyWrapper

    @Animatable(animated: Animations.TranslationAnimation(), configure: {
        if isRepeat {
            $0.autoreverses = true
            $0.repeatCount = 100
            }
    })
    var translationView: UILabel = UILabel()

    @Animatable(animated: Animations.ScaleAnimation(), configure: {
        if isRepeat {
            $0.autoreverses = true
            $0.repeatCount = 100
            }
    })
    var scaleView: UILabel = UILabel()

    @Animatable(animated: AnimationGroup(Animations.TranslationAnimation(), Animations.ScaleAnimation()), configure: {
        if isRepeat {
            $0.autoreverses = true
            $0.repeatCount = 100
            }
        })
    var combineView: UILabel = UILabel()
    
    $translationView.startAnimation()
    $scaleView.startAnimation()
    $combineView.startAnimation()

Tips

You can use projectedValue $ to startAnimation and stopAnimation

Installation

import PackageDescription

let package = Package(
name: "MyAwesomeApp",
dependencies: [
.Package(url: "https://github.com/GodL/Animatable.git", majorVersion: 1.0.6),
],
targets: [
.target(
name: "MyAwesomeApp",
dependencies: ["Animatable"])
]
)
  • Using [Cococpods]:
pod 'Animatable', '~> 1.0.6'

License

Animatable is under MIT license. See the LICENSE file for more info.

GitHub

link
Stars: 10
Last commit: 5 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API