Skip to content
This repository was archived by the owner on Aug 14, 2022. It is now read-only.

syjdev/HorizontalParallaxScrollView

Repository files navigation

SYParallaxScrollView

Version License Platform

Demo Animation

Usage

  • First, You have to define SYParallaxViewItem object.
let view = UIView(...)
let item = SYParallaxViewItem(view: view,
                      originOffset: CGPoint(x: 150, y: 80),
                      acceleration: SYParallaxAcceleration.invariable(CGPoint(x: 1, y: 1)),
                          progress: { (parallaxView, view) in
                                       //...
                                    }
                              )

If you want, You can define a dynamic acceleration.

let dynamicAcceleration = SYParallaxAcceleration.variable { (parallaxView, view) -> CGPoint in
	let progressRatio = (parallaxView.contentSize.width - 3 * parallaxView.contentOffset.x) / parallaxView.contentSize.width
	return CGPoint(x: 0.65 * progressRatio, y: 0.65 * (1 - progressRatio))
}

let view = UIView(...)
let item = SYParallaxViewItem(view: view,
                      originOffset: CGPoint(x: 150, y: 80),
                      acceleration: dynamicAcceleration,
                          progress: { (parallaxView, view) in
                                       //...
                                    }
                              )
  • Second, Build a parallaxView.
let parallaxView = SYParallaxScrollViewBuilder.setOption { (option) in
                        option.frame = CGRect(x: 0, y: 100, width: view.frame.size.width, height: view.frame.size.height - 100)
                        option.parallaxViewItems = [item] // You can add more items.
                        option.isPagingEnabled = false
                   }.build()
parallaxView.delegate = self //Optional

Requirements

Minimum iOS Target : iOS 8.0

Installation

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

pod 'SYParallaxScrollView'

Author

syjdev@gmail.com

License

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

About

Useful for Configure Horizontal Parallax Scroll.

Resources

License

Stars

Watchers

Forks

Packages

No packages published