Spring README

The project's README from github.com/MengTo/Spring. As one markdown file: README.md.

Updated for Swift 4.2

Requires Xcode 10 and Swift 4.2.

Installation

Drop in the Spring folder to your Xcode project (make sure to enable "Copy items if needed" and "Create groups").

Or via CocoaPods:

use_frameworks!
pod 'Spring', :git => 'https://github.com/MengTo/Spring.git'

Usage with Storyboard

In Identity Inspector, connect the UIView to SpringView Class and set the animation properties in Attribute Inspector.

Usage with Code

layer.animation = "squeezeDown"
layer.animate()

Demo The Animations

Chaining Animations

layer.y = -50
animateToNext {
  layer.animation = "fall"
  layer.animateTo()
}

Functions

animate()
animateNext { ... }
animateTo()
animateToNext { ... }

Animation

shake
pop
morph
squeeze
wobble
swing
flipX
flipY
fall
squeezeLeft
squeezeRight
squeezeDown
squeezeUp
slideLeft
slideRight
slideDown
slideUp
fadeIn
fadeOut
fadeInLeft
fadeInRight
fadeInDown
fadeInUp
zoomIn
zoomOut
flash

Curve

spring
linear
easeIn
easeOut
easeInOut

Properties

force
duration
delay
damping
velocity
repeatCount
scale
x
y
rotate

* Not all properties work together. Play with the demo app.

Autostart

Allows you to animate without code. Don't need to use this if you plan to start the animation in code.

Autohide

Saves you the hassle of adding a line "layer.alpha = 0" in viewDidLoad().

Known issue

Animations won't autostart when view is reached via performSegueWithIdentifier.

Tutorials

ChangeLog

License

Spring is released under the MIT license. See LICENSE for details.

Spring (MengTo/Spring)

Searching Database…

14.1K ·GitHub
这是什么?Spring 是一个用于 iOS 的 Swift 库,提供现成的视图动画(抖动、弹出、摇摆、翻转、滑动、淡入淡出、缩放等),你可以用代码触发,也可以直接在 Storyboard 中设置。
它是一个框架,还是只是个 UIView 辅助工具?它是一个轻量级的库,而不是完整的框架:它为 UIView 扩展了动画属性和函数,你可以在代码中调用;另外还提供了一个 SpringView 类,可以直接在 Storyboard 中添加。
我要怎么把它添加到我的 Xcode 项目里?将 Spring 文件夹拖入你的 Xcode 项目中(勾选 'Copy items if needed' 和 'Create groups'),或者通过 CocoaPods 安装。
它需要特定的 Xcode 或 Swift 版本吗?需要。此版本的 Spring 要求 Xcode 10 和 Swift 4.2。
动画有什么已知的坑吗?通过 performSegueWithIdentifier 跳转到某个视图时,动画不会自动开始;而且并非所有动画属性(force、duration、damping、velocity 等)都能同时使用,README 建议在示例应用中测试各种组合。
我能不写代码就触发动画吗?可以。Autostart 选项会自动播放动画;Autohide 选项则可以省去你在 viewDidLoad() 中手动设置 layer.alpha = 0 的步骤。
我能把多个动画串起来吗?可以。使用 animateToNext,可以先运行一个动画,等它结束后再启动另一个,例如先移动视图,然后让它下落。
我可以用哪些动画曲线?Spring 的动画支持 spring、linear、easeIn、easeOut 和 easeInOut 几种曲线。
我能在 Objective-C 项目里用 Spring 吗?可以。README 中链接了一篇专门介绍如何将 Spring 集成到现有 Objective-C 项目中的教程。
Creator
MengTo
Size
0.9 MB
Stars
14.1K
Updated
CommitAug 14
Age
11y
Commits · 90 Days