ScrollingFollowView is a simple view which follows UIScrollView scrolling.

Overview

ScrollingFollowView

Platform Language

ScrollingFollowView is a simple view which follows UIScrollView scrolling.

ScrollingFollowView Sample Images

  • SearchBarSample : SearchBar Area
  • ProfileViewSample : Like Profile View Area
  • BottomButtonSample : SearchBar and Bottom Button Area

Installation

CocoaPods

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

pod "ScrollingFollowView"

Then you can import it with:

import ScrollingFollowView

Carthage

ScrollingFollowView is available throught Carthage. To install it simply add the following line to your Cartfile:

github "ktanaka117/ScrollingFollowView"

Run carthage update to build the framework and drag the built ScrollingFollowView.framework into your Xcode project.

Click below link if you would like to know more about using Carthage: https://github.com/Carthage/Carthage#if-youre-building-for-ios-tvos-or-watchos

How to Use

Layout InterfaceBuilder

ScrollingFollowView only supports Autolayout use. (I don't force this feature on library users. I'm going to modify this feature. Plz look Future Improvements.) You must make layouts with InterfaceBuilder like under sample image.

Code

@IBOutlet weak var scrollingFollowView: ScrollingFollowView!

// NSLayoutConstraint of moving edge.
@IBOutlet weak var constraint: NSLayoutConstraint!

override func viewDidLoad() {
    super.viewDidLoad()

    let scrollingFollowViewHeight = scrollingFollowView.frame.size.height
    let statusBarHeight = UIApplication.sharedApplication().statusBarFrame.size.height

    // First setup
    // In default use, maxFollowPoint should be maxPoint of following to scroll DOWN.
    // In default use, minFollowPoint should be maxPoint of following to scroll UP.
    scrollingFollowView.setup(constraint: constraint, maxFollowPoint: scrollingFollowViewHeight + statusBarHeight, minFollowPoint: 0)
}
func scrollViewDidScroll(scrollView: UIScrollView) {
	// scrollingFollowView follows UIScrollView scrolling.
    scrollingFollowView.didScroll(scrollView)
}

Advanced Use

Use show(animated:) and hide(animated:)

You can use show(animated:) and hide(animated:) methods to ScrollingFollowView object like these:

// show
@IBAction func showButton() {
	scrollingFollowView.show(true)
	scrollingFollowView.resetPreviousPoint(scrollView)
}
// hide
@IBAction func hideButton() {
	scrollingFollowView.hide(false)
	scrollingFollowView.resetPreviousPoint(scrollView)
}

resetPreviousPoint(scrollView:) must call after show(animated:) and hide(animated), previousPoint is ScrollingFollowView's private property which used changing constraint.constant value.

And show and hide methods are declared as:

func show(animated: Bool, duration: Double = 0.2, completionHandler: (()->())? = nil)
func hide(animated: Bool, duration: Double = 0.2, completionHandler: (()->())? = nil)

so you can set animation duration and completionHandler which used after animation:

// show
@IBAction func showButton() {
	scrollingFollowView.show(true, duration: 0.6) { print("showed") }
	scrollingFollowView.resetPreviousPoint(scrollView)
}
// hide
@IBAction func hideButton() {
	scrollingFollowView.hide(true, duration: 0.5) { print("hid") }
	scrollingFollowView.resetPreviousPoint(scrollView)
}

Use DelayPoints

You can use hide and show delay points like under gif:

Add setupDelayPoints(pointOfStartingHiding:pointOfStartingShowing:). For example, write in viewDidLoad():

override func viewDidLoad() {
    super.viewDidLoad()

    let scrollingFollowViewHeight = scrollingFollowView.frame.size.height
    let statusBarHeight = UIApplication.sharedApplication().statusBarFrame.size.height

    scrollingFollowView.setup(constraint: constraint, maxFollowPoint: scrollingFollowViewHeight + statusBarHeight, minFollowPoint: 0)

    scrollingFollowView.setupDelayPoints(pointOfStartingHiding: 100, pointOfStartingShowing: 50)
}

Use Controlling Half-Display

You can control half-display state like under gif:

allowHalfDisplay

disallowHalfDisplay(Auto Animation)

You have to add parameter allowHalfDisplay to setup(constraint:maxFollowPoint:minFollowPoint:allowHalfDesplay:) function.

override func viewDidLoad() {
    super.viewDidLoad()

    let scrollingFollowViewHeight = scrollingFollowView.frame.size.height
    let statusBarHeight = UIApplication.sharedApplication().statusBarFrame.size.height

    // allowHalfDisplay: Default is false.
    // When allowHalfDisplay is true, ScrollingFollowView can display following scrolling state.
    // When allowHalfDisplay is false, ScrollingFollowView can't display following scrolling state. (If ScrollingFollowView is half-display state, it automatically animates.)
    scrollingFollowView.setup(constraint: constraint, maxFollowPoint: scrollingFollowViewHeight + statusBarHeight, minFollowPoint: 0, allowHalfDisplay: true)
}

and you also have to call didEndScrolling() and didEndScrolling(_ decelerate:) at scrollViewDidEndDecelerating(_ scrollView:) and scrollViewDidEndDragging(_ scrollView:willDecelerate:).

extension ViewController: UIScrollViewDelegate {
    func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
        navBarScrollingFollowView.didEndScrolling()
    }
    
    func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
        navBarScrollingFollowView.didEndScrolling(decelerate)
    }
}

Runtime Requirements

  • iOS 8.0 or later
  • Swift 3.0 or later
  • Xcode 8.0 or later

Future Improvements

  • Refactoring. ๐Ÿ’ช
  • Enable to use like UITabBarController.
  • Enable to implement only using code.
  • Enable to move ScrollingFollowView using frame layout.
  • Enable to horizontally move ScrollingFollowView.
  • Enable to manage constraint without passing constraint argument. (I think we only want to chose an edge which follows scrolling. Like .Top, .Bottom, .Left, .Right.)

Contact

When you have some opinions or ideas about this library, send me a reply on Twitter. ๐Ÿฃ @ktanaka117

License

ScrollingFollowView is released under the MIT license. Go read the LICENSE file for more information.

You might also like...
Full configurable spreadsheet view user interfaces for iOS applications. With this framework, you can easily create complex layouts like schedule, gantt chart or timetable as if you are using Excel.
Full configurable spreadsheet view user interfaces for iOS applications. With this framework, you can easily create complex layouts like schedule, gantt chart or timetable as if you are using Excel.

kishikawakatsumi/SpreadsheetView has moved! It is being actively maintained at bannzai/SpreadsheetView. This fork was created when the project was mov

iOS custom view to display books on shelf
iOS custom view to display books on shelf

ShelfView (iOS) iOS custom view to display books on shelf (Android version is available here) Requirements iOS 10.0+ Swift 4.2 Installation ShelfView

A non gesture blocking, non clipping by default custom scroll view implementation with example code

A non gesture blocking, non clipping by default custom scroll view implementation with example code

OpenSwiftUIViews - A non gesture blocking, non clipping by default custom scroll view implementation with example code.

OpenSwiftUIViews - A non gesture blocking, non clipping by default custom scroll view implementation with example code.

Scrollable UINavigationBar that follows the scrolling of a UIScrollView
Scrollable UINavigationBar that follows the scrolling of a UIScrollView

A custom UINavigationController that enables the scrolling of the navigation bar alongside the scrolling of an observed content view Versioning notes

Scrollable UINavigationBar that follows the scrolling of a UIScrollView
Scrollable UINavigationBar that follows the scrolling of a UIScrollView

A custom UINavigationController that enables the scrolling of the navigation bar alongside the scrolling of an observed content view Versioning notes

A container view that responds to scrolling of UIScrollView
A container view that responds to scrolling of UIScrollView

FlexibleHeader A container view that responds to scrolling of UIScrollView. normal threshold FlexibleHeaderExecutantType Getting Started Progressive I

Give pull-to-refresh & infinite scrolling to any UIScrollView with 1 line of code.

SVPullToRefresh + SVInfiniteScrolling These UIScrollView categories makes it super easy to add pull-to-refresh and infinite scrolling fonctionalities

Multi-tier UIScrollView nested scrolling solution. ๐Ÿ˜‹๐Ÿ˜‹๐Ÿ˜‹
Multi-tier UIScrollView nested scrolling solution. ๐Ÿ˜‹๐Ÿ˜‹๐Ÿ˜‹

Multi-tier UIScrollView nested scrolling solution. Snapshots Requirements iOS 9.0+ Xcode 10.0+ Swift 4.2+ Installation CocoaPods CocoaPods is a depend

AutoKeyboardScrollView is an UIScrollView subclass which makes showing and dismissing keyboard for UITextFields much easier. So called keyboard avoidance.
AutoKeyboardScrollView is an UIScrollView subclass which makes showing and dismissing keyboard for UITextFields much easier. So called keyboard avoidance.

AutoKeyboardScrollView AutoKeyboardScrollView is a smart UIScrollView which can: Scroll to proper position and make sure the active textField is visib

๐Ÿ›  WormTabStrip ViewPager for iOS written in Swift, which gives continuous feedback to the user when scrolling
๐Ÿ› WormTabStrip ViewPager for iOS written in Swift, which gives continuous feedback to the user when scrolling

Worm Tab Strip Worm Tab Strip is inspired by android SmartTabStrip, android view pager like library for iOS written in swift. Basically it was build u

A custom ViewPager title strip which gives continuous feedback to the user when scrolling
A custom ViewPager title strip which gives continuous feedback to the user when scrolling

SmartTabLayout A custom ViewPager title strip which gives continuous feedback to the user when scrolling. This library has been added some features an

A PageView, which supporting scrolling to transition between a UIView and a UITableView
A PageView, which supporting scrolling to transition between a UIView and a UITableView

YXTPageView ##A Page View, which support scrolling to transition between a UIView and a UITableView UIView (at the top) UITableView (at the bottom) In

A custom stretchable header view for UIScrollView or any its subclasses with UIActivityIndicatorView and iPhone X safe area support for content reloading. Built for iOS 10 and later.

Arale A custom stretchable header view for UIScrollView or any its subclasses with UIActivityIndicatorView support for reloading your content. Built f

List a collection of items in a horizontally scrolling view. A scaling factor controls the size of the items relative to the center.
List a collection of items in a horizontally scrolling view. A scaling factor controls the size of the items relative to the center.

CAROUSEL List a collection of items in a horizontally scrolling view. A scaling factor controls the size of the items relative to the center. We speci

A custom image view that implements device motion scrolling
A custom image view that implements device motion scrolling

YXTMotionView A custom image view that implements device motion scrolling Installation CocoaPods Add the dependency to your Podfile: platform :ios pod

Parallax scrolling effect on UITableView header view when a tableView is scrolled
Parallax scrolling effect on UITableView header view when a tableView is scrolled

ParallaxTableViewHeader Parallax scrolling effect on UITableView header view when a tableView is scrolled Usage Create a ParallaxHeaderView using eith

Horizontal and Vertical collection view for infinite scrolling that was designed to be used in SwiftUI
Horizontal and Vertical collection view for infinite scrolling that was designed to be used in SwiftUI

InfiniteScroller Example struct ContentView: View { @State var selected: Int = 1 var body: some View { InfiniteScroller(direction: .ve

BWMCoverView is a very easy to use advertising the carousel view, supports circular scrolling functions such as switching, asynchronous loading of images, animation, custom is very high.
BWMCoverView is a very easy to use advertising the carousel view, supports circular scrolling functions such as switching, asynchronous loading of images, animation, custom is very high.

BWMCoverView BWMCoverView is a very easy to use advertising the carousel view, supports circular scrolling functions such as switching, asynchronous l

Comments
  • Support modern build system

    Support modern build system

    Xcode 10ใ‹ใ‚‰ๅฐŽๅ…ฅใ•ใ‚ŒใŸๆ–ฐใ—ใ„ใƒ“ใƒซใƒ‰ใ‚ทใ‚นใƒ†ใƒ ใซใ‚ˆใ‚Šใƒ“ใƒซใƒ‰ใงใใชใใชใ‚Šใพใ—ใŸใฎใงไฟฎๆญฃใ—ใพใ—ใŸใ€‚

    ใ‚„ใฃใŸใ“ใจ

    • gitignoreใฎใ‚ขใƒƒใƒ—ใƒ‡ใƒผใƒˆ
    • ใƒฉใ‚คใƒ–ใƒฉใƒชใƒ—ใƒญใ‚ธใ‚งใ‚ฏใƒˆใจใ‚ตใƒณใƒ—ใƒซใƒ—ใƒญใ‚ธใ‚งใ‚ฏใƒˆใ‚’ๅˆ†ๅ‰ฒ
    • ใ‚ตใƒณใƒ—ใƒซใƒ—ใƒญใ‚ธใ‚งใ‚ฏใƒˆใฎใŸใ‚ใซใ—ใฆใ„ใŸใ‚ณใƒ”ใƒผใฎใƒ“ใƒซใƒ‰ใƒ•ใ‚งใƒผใ‚บใ‚’ๅ‰Š้™ค
      • ใ“ใ“ใŒใƒ“ใƒซใƒ‰ใงใใชใ„ๅŽŸๅ› ใงใ—ใŸใ€‚ http://kumamotone.hatenadiary.jp/entry/2018/09/19/010501
    opened by tomorrowkey 1
  • ScrollingFollowView y-position repeat up and down

    ScrollingFollowView y-position repeat up and down

    What

    There is a view which is installed a ScrollingFollowView and UITableView on ContainerView. When adding data to datasource of tableview, ScrollingFollowView repeats up and down that's y-position.

    opened by ktanaka117 0
Releases(1.1.1)
  • 1.1.1(Feb 2, 2017)

  • 1.0.1(Nov 2, 2016)

  • 1.0.0(Sep 22, 2016)

    1.0.0 Release notes(2016/09/20)

    Congraturation! Version 1.0.0 is Released!!!

    New Feature

    • ** Migrating to Swift 3.0!! **
    • Enable to control allow/disallow half-display state.
    Source code(tar.gz)
    Source code(zip)
  • 0.3.1(Aug 10, 2016)

    0.3.1 Release notes(2016/08/10)

    Improvement

    • delete unnecessary param in isTopOrBottomEdge. #1 @tototti
    • fix UIView animation. #2 @tototti

    Contributor

    @tototti

    Thank you very much!

    Source code(tar.gz)
    Source code(zip)
  • 0.3.0(Aug 10, 2016)

  • 0.2.0(Aug 3, 2016)

  • 0.1.0(Jul 27, 2016)

Owner
Tanaka Kenji
iOS Engineer๐Ÿ“ฆ
Tanaka Kenji
AutoKeyboardScrollView is an UIScrollView subclass which makes showing and dismissing keyboard for UITextFields much easier. So called keyboard avoidance.

AutoKeyboardScrollView AutoKeyboardScrollView is a smart UIScrollView which can: Scroll to proper position and make sure the active textField is visib

HongHao Zhang 120 Jul 31, 2022
HPParallaxHeader is a simple parallax header class for UIScrollView.

HPParallaxHeader is a simple parallax header class for UIScrollView.

null 40 Dec 15, 2022
UIScrollView โˆž scroll category

UIScrollView+InfiniteScroll Infinite scroll implementation as a category for UIScrollView. * The content used in demo app is publicly available and pr

Andrej Mihajlov 1k Dec 29, 2022
GoAutoSlideView extends UIScrollView by featuring infinitely and automatically slide.

GoAutoSlideView GoAutoSlideView extends UIScrollView by featuring infinitely and automatically slide. #ScreenShot Installation ###CocoaPods pod 'GoAut

Jamie 57 Jan 12, 2021
A data-driven UIScrollView + UIStackView framework for building fast and flexible lists

JKListKit A data-driven UIScrollView + UIStackView framework for building fast and flexible lists. Full Oficial documentation Main Features ?? Create

Juan Vasquez 2 Mar 15, 2022
SwiftUI, peek scrolling animation and card tapped animation, using GeometryReader

SwiftUI, peek scrolling animation and card tapped animation, using GeometryReader, follow the livestream tutorial by MengTo.

Terry Kuo 4 Jun 10, 2022
CrownControl is a tiny accessory that makes scrolling through scrollable content possible without lifting your thumb.

CrownControl Overview Features Example Project Requirements Installation Usage Quick Usage Crown Attributes Scroll Axis Anchor Position Spin Direction

Daniel Huri 96 Dec 27, 2022
Simultaneously scrolling ScrollViews with SwiftUI support

SimultaneouslyScrollView Simultaneously scrolling ScrollViews with SwiftUI support Installation Swift Package Manager Usage SwiftUI support Example In

David Steinacher 8 Aug 19, 2022
A scroll view with a sticky header which shrinks as you scroll. Written with SwiftUI.

Scaling Header Scroll View A scroll view with a sticky header which shrinks as you scroll. Written with SwiftUI. We are a development agency building

Exyte 395 Dec 31, 2022
App store style horizontal scroll view

ASHorizontalScrollView App store style horizontal scroll view It acts similar to apps sliding behaviours in App store. There are both Objective-C (do

Terence Chen 663 Nov 26, 2022