ParallaxScrollable
public protocol ParallaxScrollable: UIScrollViewDelegate
Protocol extending UIScrollViewDelegate to adjust the scrolling of a given view to mimic a parallax motion between the two views.
Default implementations are given for parallaxScrollViewDidScroll(_:) on all adopters, and for configureParallaxScrollInset(_:) for UIViewControllers.
-
The reference view that the
UIScrollViewwill scroll over, whose position is adjusted on scrolling theUIScrollView.Declaration
Swift
var parallaxHeaderView: UIView! { get } -
The
UIScrollViewwhose offset drives the parallax motion of theheaderView.Declaration
Swift
var parallaxScrollView: UIScrollView! { get set } -
The mask applied to the
parallaxHeaderViewthat provides clipping ofparallaxHeaderViewif the content of aparallaxScrollViewis short enough for theparallaxHeaderViewto be visible underneath the scrollable content.Declaration
Swift
var parallaxHeaderMask: CAShapeLayer { get } -
The parallax motion of the
headerViewis implemented by setting theconstantproperty of this constraint.Declaration
Swift
var parallaxHeaderViewTopConstraint : NSLayoutConstraint! { get set } -
configureParallaxScrollInset(_:)Default implementationShould set the
contentInsetof theparallaxScrollViewto allow theheaderViewto be seen above the content ofparallaxScrollView.Default Implementation
Default implementation of
configureParallaxScrollInset(_:)forUIViewControllers.Sets the content inset of
parallaxScrollViewto allow theheaderViewto be fully visible above the content of theparallaxScrollView. The bottom inset of theparallaxScrollViewis adjusted to allow the content to be visible above thebottomLayoutGuide. This will typically by called fromviewDidLayoutSubviews(), to reset thecontentInsetas the size of other content changes.headerOverlap()andbottomOverlap()are used to calculate the necessary values.Declaration
Swift
func configureParallaxScrollInset(minimumHeight:CGFloat) -
parallaxScrollViewDidScroll(_:scrollRate:bouncesHeader:maskingHeader:)Default implementationShould update
headerViewTopConstraint.constantto mimic a parallax motion. With the given parameter. A default implementation is given.Default Implementation
Default implementation for parallax scrolling a header view. Typically this will be called from
scrollViewDidScroll:.Declaration
Swift
func parallaxScrollViewDidScroll(scrollView:UIScrollView, scrollRate:CGFloat, bouncesHeader:Bool, maskingHeader:Bool)
-
parallaxHeaderOverlap()Extension methodDeclaration
Swift
public func parallaxHeaderOverlap() -> CGRectReturn Value
The intersection of
headerViewandparallaxScrollViewin the frame ofparallaxScrollView.superview. -
parallaxBottomOverlap()Extension methodDeclaration
Swift
public func parallaxBottomOverlap() -> CGRectReturn Value
The intersection of
the bottomLayoutGuideandparallaxScrollViewin the frame ofparallaxScrollView.superview.
-
updateParallaxHeaderMask()Extension methodUpdates
parallaxHeaderMaskto clip theparallaxHeaderView, preventing it being seen beneath short content.Declaration
Swift
public func updateParallaxHeaderMask()
View on GitHub
ParallaxScrollable Protocol Reference