Skip to content

A simple approach implementing Breath animation (Apple Watch app).

Notifications You must be signed in to change notification settings

victorpanitz/iOS-BreathAnimation-AppleWatch-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

Breath Animation (Smartch Watch App)

A simple approach implementing Breath animation (Apple Watch app).

alt text



Flexible

This model is able to receive animation settings as duration, repeat count and autoreverse. Generate your breath animating using BreathLayerGenerator choosing the number of circles you want.


import UIKit

final class BreathViewController: UIViewController {
    
    var generator: BreathLayerGenerator?
    var animator: BreathAnimator?
    lazy var layers = [CAShapeLayer]()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        view.backgroundColor = .black
        
        generator = BreathLayerGenerator(center: view.center)
        animator = BreathAnimator(duration: 4, repeatCount: 3, autoreverse: true)
        
        setupBreath()
    }
    
    private func setupBreath(){
        guard let layers = generator?.generateLayers(numberOfLayers: 6) else { return }
        layers.forEach { view.layer.addSublayer($0) }
        
        animator?.animate(layers: layers)
    }
}

About

A simple approach implementing Breath animation (Apple Watch app).

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages