Latest 0.1.1
Homepage https://github.com/heart/SwiftTween
License MIT
Platforms ios 8.0
Authors

SwiftTween Logo

CI Status
Version
License
Platform

SwiftTween is a lightweight value tweener easy to use.

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

the Example project

SwiftTween Example app

Requirements

Swift 4.0

Installation

SwiftTween is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'SwiftTween'

Example

let view = UIView()
view.layer.backgroundColor = UIColor.red.cgColor
view.frame = CGRect(x: 0, y: 0, width: 100, height: 100)

let t = SwiftTween()

t.onUpdate = {
    (value:Double,timePassed:Double,finish:Bool)->Void in

    let f = view.frame

    view.frame = CGRect(x:CGFloat(value-20) ,
                            y:CGFloat(200-value),
                            width:f.size.width,
                            height:f.size.height)

    if finish {
        print("Tween Finished")
    }else{
        print("Time Passed > (timePassed)")
    }

}

t.tween(startValue:0, endValue:200 , timeDuration:1 , ease:Ease.Linear )

You can get the tween value at any spot of the timline

let duration = 20
let currentTime = 10
let beginningValue = 0
let finalValue = 100

let value_At_Half_Of_Timeline = EasingFunction.getValue( 
                ease:Ease.Linear, 
                currentTime: currentTime, 
                beginningValue: beginningValue, 
                finalValue: finalValue , 
                totalDuration:duration )

print( value_At_Half_Of_Timeline ) //print 50 because it's a Linear easing

You also can get the ratio of value at any spot of the timline

let timelineRatio = 0.5

let value_Ratio_At_Half_Of_Timeline = EasingFunction.getRatio(ease:Ease.Linear,  timeRatio:timelineRatio )

print( value_At_Half_Of_Timeline ) //print 0.5 because it's a Linear easing

Easing Type

Ease.Linear
Ease.InQuad
Ease.OutQuad
Ease.InOutQuad
Ease.InCubic
Ease.OutCubic
Ease.InOutCubic
Ease.InQuart
Ease.OutQuart
Ease.InOutQuart
Ease.InQuint
Ease.OutQuint
Ease.InOutQuint
Ease.InSine
Ease.OutSine
Ease.InOutSine
Ease.InExpo
Ease.OutExpo
Ease.InOutExpo
Ease.InCirc
Ease.OutCirc
Ease.InOutCirc
Ease.InElastic
Ease.OutElastic
Ease.InOutElastic
Ease.InBack
Ease.OutBack
Ease.InOutBack
Ease.InBounce
Ease.OutBounce
Ease.InOutBounce

Author

i am Heart, [email protected]

License

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

Latest podspec

{
    "name": "SwiftTween",
    "version": "0.1.1",
    "summary": "SwiftTween is a lightweight Value Tweening for iOS.",
    "description": "SwiftTween is a lightweigh value tween fot iOS.nIt's Write on Swift 4.0.",
    "homepage": "https://github.com/heart/SwiftTween",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "i am Heart": "[email protected]"
    },
    "source": {
        "git": "https://github.com/heart/SwiftTween.git",
        "tag": "0.1.1"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "SwiftTween/Classes/**/*",
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This