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 UIScrollView will scroll over, whose position is adjusted on scrolling the UIScrollView.

    Declaration

    Swift

    var parallaxHeaderView: UIView!  { get }
  • The UIScrollView whose offset drives the parallax motion of the headerView.

    Declaration

    Swift

    var parallaxScrollView: UIScrollView!  { get set }
  • The mask applied to the parallaxHeaderView that provides clipping of parallaxHeaderView if the content of a parallaxScrollView is short enough for the parallaxHeaderView to be visible underneath the scrollable content.

    Declaration

    Swift

    var parallaxHeaderMask: CAShapeLayer { get }
  • The parallax motion of the headerView is implemented by setting the constant property of this constraint.

    Declaration

    Swift

    var parallaxHeaderViewTopConstraint : NSLayoutConstraint!  { get set }
  • configureParallaxScrollInset(_:) Default implementation

    Should set the contentInset of the parallaxScrollView to allow the headerView to be seen above the content of parallaxScrollView.

    Default Implementation

    Default implementation of configureParallaxScrollInset(_:) for UIViewControllers.

    Sets the content inset of parallaxScrollView to allow the headerView to be fully visible above the content of the parallaxScrollView. The bottom inset of the parallaxScrollView is adjusted to allow the content to be visible above the bottomLayoutGuide. This will typically by called from viewDidLayoutSubviews(), to reset the contentInset as the size of other content changes.

    headerOverlap() and bottomOverlap() are used to calculate the necessary values.

    Declaration

    Swift

    func configureParallaxScrollInset(minimumHeight:CGFloat)
  • Should update headerViewTopConstraint.constant to 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 method

    Declaration

    Swift

    public func parallaxHeaderOverlap() -> CGRect

    Return Value

    The intersection of headerView and parallaxScrollView in the frame of parallaxScrollView.superview.

  • parallaxBottomOverlap() Extension method

    Declaration

    Swift

    public func parallaxBottomOverlap() -> CGRect

    Return Value

    The intersection of the bottomLayoutGuide and parallaxScrollView in the frame of parallaxScrollView.superview.