GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - MarcoBay/SpringAnimationCALayer: A helper function for animating CALayer with spring effect in Swift

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

75 Commits
75 Commits

Folders and files

NameName
Last commit message
Last commit date
SpringAnimationCALayer.xcodeproj
SpringAnimationCALayer.xcodeproj
 
 
SpringAnimationCALayer
SpringAnimationCALayer
 
 
SpringAnimationCALayerTests
SpringAnimationCALayerTests
 
 
graphics
graphics
 
 
.gitignore
.gitignore
 
 
README.md
README.md
 
 
iiQ.swift
iiQ.swift
 
 

Repository files navigation

Animating CALayer with spring effect in iOS with Swift.

This demo app shows how to do spring animation on CALayer. Animation is similar to UIView's method animateWithDuration(_:delay:usingSpringWithDamping:...).

Usage

  1. Copy SpringAnimation.swift file to your project.
  2. Animate your CALayer's property by calling SpringAnimation.animate function.

For example, let's rotate a button's layer around its X axis in perspective:

let myCALayer = button.layer
var transform = CATransform3DIdentity
transform.m34 = -1.0/100.0
myCALayer.transform = CATransform3DRotate(transform, 0, 1, 0, 0)

SpringAnimation.animate(myCALayer,
                        keypath: "transform.rotation.x",
                        duration: 3.0,
                        usingSpringWithDamping: 0.7,
                        initialSpringVelocity: 1.7,
                        fromValue: M_PI,
                        toValue: 0,
                        onFinished: nil)

Rotate a button around X axis in iOS/Swift

Currently animation looks similar to UIView's method. But the duration, usingSpringWithDamping and initialSpringVelocity values are different from those in UIView's method.

Formula

Here is the formula that I am currently using for animation.

https://www.desmos.com/calculator/pwcg0pepqy

Spring animation formula

The Goal

The goal of this project is to make this CALayer's animation work exactly like UIView's for the same arguments.

Help me, Finn and Jake. You're my only hope.

•ᴥ•

Spring animation for CALayer in iOS with Swift

About

A helper function for animating CALayer with spring effect in Swift

Resources

Readme
Activity

Stars

0 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.