{"id":2731,"url":"https://github.com/ktanaka117/ScrollingFollowView","last_synced_at":"2025-08-03T00:32:38.270Z","repository":{"id":62455114,"uuid":"63863741","full_name":"ktanaka117/ScrollingFollowView","owner":"ktanaka117","description":"ScrollingFollowView is a simple view which follows UIScrollView scrolling.","archived":false,"fork":false,"pushed_at":"2018-11-12T06:37:52.000Z","size":3846,"stargazers_count":187,"open_issues_count":3,"forks_count":17,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-04-24T14:51:32.054Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ktanaka117.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-21T11:28:17.000Z","updated_at":"2023-08-31T15:23:00.000Z","dependencies_parsed_at":"2022-11-02T00:01:37.067Z","dependency_job_id":null,"html_url":"https://github.com/ktanaka117/ScrollingFollowView","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktanaka117%2FScrollingFollowView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktanaka117%2FScrollingFollowView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktanaka117%2FScrollingFollowView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktanaka117%2FScrollingFollowView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ktanaka117","download_url":"https://codeload.github.com/ktanaka117/ScrollingFollowView/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228510787,"owners_count":17931765,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-01-05T20:16:21.350Z","updated_at":"2024-12-06T18:30:45.408Z","avatar_url":"https://github.com/ktanaka117.png","language":"Swift","funding_links":[],"categories":["UI","Swift"],"sub_categories":["ScrollView","Layout","Other free courses"],"readme":"# ScrollingFollowView\n\n[![Platform](http://img.shields.io/badge/platform-ios-blue.svg?style=flat\n)](https://developer.apple.com/iphone/index.action)\n[![Language](http://img.shields.io/badge/language-swift-brightgreen.svg?style=flat\n)](https://developer.apple.com/swift)\n\u003ca href=\"https://github.com/Carthage/Carthage/\"\u003e\u003cimg src=\"https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat\"\u003e\u003c/a\u003e\n\nScrollingFollowView is a simple view which follows UIScrollView scrolling.\n\n#### ScrollingFollowView Sample Images\n- SearchBarSample    : SearchBar Area\n- ProfileViewSample  : Like Profile View Area\n- BottomButtonSample : SearchBar and Bottom Button Area\n\n![](./SampleImage/SearchBarSample.gif)\n![](./SampleImage/ProfileViewSample.gif)\n![](./SampleImage/BottomButtonSample.gif)\n\n## Installation\n### CocoaPods\nScrollingFollowView is available through [CocoaPods](http://cocoapods.org). To install it simply add the following line to your Podfile:\n\n```\npod \"ScrollingFollowView\"\n```\n\nThen you can import it with:\n\n```\nimport ScrollingFollowView\n```\n\n### Carthage\nScrollingFollowView is available throught [Carthage](https://github.com/Carthage/Carthage). To install it simply add the following line to your Cartfile:\n\n```\ngithub \"ktanaka117/ScrollingFollowView\"\n```\n\nRun `carthage update` to build the framework and drag the built `ScrollingFollowView.framework` into your Xcode project.\n\nClick 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\n\n## How to Use\n### Layout InterfaceBuilder\nScrollingFollowView only supports Autolayout use. \n(I don't force this feature on library users. I'm going to modify this feature. Plz look Future Improvements.)\nYou must make layouts with InterfaceBuilder like under sample image.\n\n![](./SampleImage/HowToUse.png)\n![](./SampleImage/module.jpg)\n\n### Code\n```swift\n@IBOutlet weak var scrollingFollowView: ScrollingFollowView!\n\n// NSLayoutConstraint of moving edge.\n@IBOutlet weak var constraint: NSLayoutConstraint!\n\noverride func viewDidLoad() {\n    super.viewDidLoad()\n\n    let scrollingFollowViewHeight = scrollingFollowView.frame.size.height\n    let statusBarHeight = UIApplication.sharedApplication().statusBarFrame.size.height\n\n    // First setup\n    // In default use, maxFollowPoint should be maxPoint of following to scroll DOWN.\n    // In default use, minFollowPoint should be maxPoint of following to scroll UP.\n    scrollingFollowView.setup(constraint: constraint, maxFollowPoint: scrollingFollowViewHeight + statusBarHeight, minFollowPoint: 0)\n}\n```\n\n```swift\nfunc scrollViewDidScroll(scrollView: UIScrollView) {\n\t// scrollingFollowView follows UIScrollView scrolling.\n    scrollingFollowView.didScroll(scrollView)\n}\n```\n\n## Advanced Use\n### Use show(animated:) and hide(animated:)\nYou can use `show(animated:)` and `hide(animated:)` methods to ScrollingFollowView object like these:\n\n```swift\n// show\n@IBAction func showButton() {\n\tscrollingFollowView.show(true)\n\tscrollingFollowView.resetPreviousPoint(scrollView)\n}\n// hide\n@IBAction func hideButton() {\n\tscrollingFollowView.hide(false)\n\tscrollingFollowView.resetPreviousPoint(scrollView)\n}\n```\n\n`resetPreviousPoint(scrollView:)` must call after `show(animated:)` and `hide(animated)`, `previousPoint` is ScrollingFollowView's private property which used changing constraint.constant value.\n\nAnd show and hide methods are declared as:\n```swift\nfunc show(animated: Bool, duration: Double = 0.2, completionHandler: (()-\u003e())? = nil)\nfunc hide(animated: Bool, duration: Double = 0.2, completionHandler: (()-\u003e())? = nil)\n```\n\nso you can set `animation duration` and `completionHandler` which used after animation:\n\n```swift\n// show\n@IBAction func showButton() {\n\tscrollingFollowView.show(true, duration: 0.6) { print(\"showed\") }\n\tscrollingFollowView.resetPreviousPoint(scrollView)\n}\n// hide\n@IBAction func hideButton() {\n\tscrollingFollowView.hide(true, duration: 0.5) { print(\"hid\") }\n\tscrollingFollowView.resetPreviousPoint(scrollView)\n}\n```\n\n### Use DelayPoints\nYou can use hide and show delay points like under gif:\n\n![](./SampleImage/DelaySample.gif)\n\nAdd `setupDelayPoints(pointOfStartingHiding:pointOfStartingShowing:)`.\nFor example, write in `viewDidLoad()`:\n\n```swift\noverride func viewDidLoad() {\n    super.viewDidLoad()\n\n    let scrollingFollowViewHeight = scrollingFollowView.frame.size.height\n    let statusBarHeight = UIApplication.sharedApplication().statusBarFrame.size.height\n\n    scrollingFollowView.setup(constraint: constraint, maxFollowPoint: scrollingFollowViewHeight + statusBarHeight, minFollowPoint: 0)\n\n    scrollingFollowView.setupDelayPoints(pointOfStartingHiding: 100, pointOfStartingShowing: 50)\n}\n```\n\n### Use Controlling Half-Display\n\nYou can control half-display state like under gif:\n\nallowHalfDisplay\n\n![](./SampleImage/allowHalfDisplay.gif)\n\ndisallowHalfDisplay(Auto Animation)\n\n![](./SampleImage/disallowHalfDisplay.gif)\n\nYou have to add parameter `allowHalfDisplay` to `setup(constraint:maxFollowPoint:minFollowPoint:allowHalfDesplay:)` function.\n\n```swift\noverride func viewDidLoad() {\n    super.viewDidLoad()\n\n    let scrollingFollowViewHeight = scrollingFollowView.frame.size.height\n    let statusBarHeight = UIApplication.sharedApplication().statusBarFrame.size.height\n\n    // allowHalfDisplay: Default is false.\n    // When allowHalfDisplay is true, ScrollingFollowView can display following scrolling state.\n    // When allowHalfDisplay is false, ScrollingFollowView can't display following scrolling state. (If ScrollingFollowView is half-display state, it automatically animates.)\n    scrollingFollowView.setup(constraint: constraint, maxFollowPoint: scrollingFollowViewHeight + statusBarHeight, minFollowPoint: 0, allowHalfDisplay: true)\n}\n```\n\nand you also have to call `didEndScrolling()` and `didEndScrolling(_ decelerate:)` at `scrollViewDidEndDecelerating(_ scrollView:)` and `scrollViewDidEndDragging(_ scrollView:willDecelerate:)`.\n\n```swift\nextension ViewController: UIScrollViewDelegate {\n    func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {\n        navBarScrollingFollowView.didEndScrolling()\n    }\n    \n    func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {\n        navBarScrollingFollowView.didEndScrolling(decelerate)\n    }\n}\n```\n\n## Runtime Requirements\n\n- iOS 8.0 or later\n- Swift 3.0 or later\n- Xcode 8.0 or later\n\n## Future Improvements\n- Refactoring.💪\n- Enable to use like UITabBarController.\n- Enable to implement only using code.\n- Enable to move ScrollingFollowView using frame layout.\n- Enable to horizontally move ScrollingFollowView.\n- 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.)\n\n## Contact\nWhen you have some opinions or ideas about this library, send me a reply on Twitter.🍣\n[@ktanaka117](https://twitter.com/ktanaka117)\n\n## License\nScrollingFollowView is released under the MIT license. Go read the LICENSE file for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fktanaka117%2FScrollingFollowView","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fktanaka117%2FScrollingFollowView","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fktanaka117%2FScrollingFollowView/lists"}