Latest 0.0.3
Homepage https://github.com/AmyF/UKAnimation
License Apache License 2.0
Platforms ios 9.0, requires ARC
Authors

CoreAnimation的链式调用的封装

Pod

pod ‘UKAnimation’

Example

UKAnimation(animView).shakeR().run()

或者你可以组合多个动画

UKAnimation(animView)
    .move(to: [100,100]).stay()
    .fade(from: 1, to: 0).modify{$0?.autoreverses = true}.stay()
    .move(to: [300,400]).after(begin: 1, willGroup: true).stay()
    .shakeR(radian:10, times:4, duration:0.5).after(begin: 1.5, willGroup: true)
    .group().duration(2).modify{$0?.autoreverses = true}
    .run()

Usage

使用的时候,如果不满意当前 CAAnimation ,你可以使用 modify(aniamtion handler: (A?) -> Swift.Void) 去修改最后一个添加的动画

UKAnimation./* animation */.modify{$0?.autoreverses = true}.run()

UKAnimation也提供了 forEach 去遍历每一个 animation

handler(begin: Item.Handler? = default, end: Item.Handler? = default) 可以对最后一个 animation 设置回调

除了自带的几个小动画,你也可以通过 extension 去添加动画

extension UKAnimation {
// code your animation
} 

或者 add(animation: CAAnimation)

UKAnimation(animView).add { return /* your animation */}.run()

Notice

所有的修改、合并、监听操作都是针对最后一个添加的 animation
当你使用 after(begin offset: CFTimeInterval, willGroup: Bool = default) 的时候
你需要确定之后是否会将这个 animation 加入一个 CAAnimationGroup 否则动画会出现紊乱

UKNoAnimation

你可以通过这个类来制作 CAAnimation 或者一堆 CAAnimation

let animations: [CAAnimation] = UKNoAnimation().fade(from: 1, to: 0).allAnimation()
let animation: CAAnimation? = UKNoAnimation().fade(from: 1, to: 0).animation(by:"name")

Latest podspec

{
    "name": "UKAnimation",
    "version": "0.0.3",
    "summary": "UKAnimationu5bf9CAAnimationu8fdbu884cu4e86u5c01u88c5u5e76u4e14u63d0u4f9bu4e86u4e00u4e9bu7b80u5355u7684u52a8u753b",
    "homepage": "https://github.com/AmyF/UKAnimation",
    "license": {
        "type": "Apache License 2.0",
        "file": "LICENSE"
    },
    "authors": {
        "unko": "[email protected]"
    },
    "platforms": {
        "ios": "9.0"
    },
    "source": {
        "git": "https://github.com/AmyF/UKAnimation.git",
        "tag": "0.0.3"
    },
    "source_files": [
        "Source",
        "Source/**/*.{swift,h,m}"
    ],
    "swift_version": "4.0",
    "requires_arc": true
}

Pin It on Pinterest

Share This