Skip to content

A tool written in swift to generate parallax animation during sliding a scroll view.

Notifications You must be signed in to change notification settings

Mamong/ParallaxKit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ParallaxKit

A tool written in swift to generate parallax animation during sliding a scroll view.

usage

1.create a ParallaxManager with a scrollview

pm = ParallaxManager.init(with: scrollView, direction: .down)

2.set backgroundImage, not required

pm?.backgroundImage = UIImage.init(named: "bg2.jpg")

3.addKeyFrameAnimation, certainly you should create several pages in advance

pm?.addKeyFrameAnimation(animation: [
    "wrapper" : intro,
    "duration" : "100%",
    "animations" :  [
        [
            "view"    : intro.nameLabel,
            "translateY"  : -140,
            "opacity"     : 0
        ] , [
            "view"    : intro.descLabel,
            "translateY"  : -110,
            "opacity"     : 0
        ]
    ]
])

Key Frame Animation is described using dictionary literal.

4.you should call generateKeyFrameAnimations() when you finish step 3.

pm?.generateKeyFrameAnimations()

5.in UIScrollviewDelegate method scrollViewDidScroll(_:), you should call the same method to perform animations.

pm?.scrollViewDidScroll(scrollView)

screenshot

About

A tool written in swift to generate parallax animation during sliding a scroll view.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages