• Stars
    star
    166
  • Rank 227,748 (Top 5 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created over 12 years ago
  • Updated over 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Like Path's timestamp scrollbar label.

MDCScrollBarLabel

An animated scroll bar to present extra information when scrolling on a UIScrollView.

Y'know, like the clock on Path.

MDCScrollBarLabel GIF

Usage

Basically, you have two options. You can:

  • Subclass MDCScrollBarViewController and set an MDCScrollBarLabel to its scrollBarLabel property.
  • Implement a UIViewController which is a UIScrollBarDelegate, then call the fade in/out logic for the label as you'd like.

See the example application for usage.

Subclassing MDCScrollBarViewController

#pragma mark - Creating the Scroll Bar Label

- (void)viewDidLoad {
    [super viewDidLoad];

    // Create a table view with a row height of 100.f
    CGSize size = self.view.frame.size;
    self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds
                                                  style:UITableViewStylePlain];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.rowHeight = 100.f;
    [self.view addSubview:self.tableView];

    // Add a scroll bar label to the table view
    self.scrollBarLabel = [[MDCScrollBarLabel alloc] initWithScrollView:self.tableView];
    [self.tableView addSubview:self.scrollBarLabel];
}

#pragma mark - Updating the Date on the Scroll Bar Label

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    [super scrollViewDidScroll:scrollView];

    // Determine which row the scroll bar label is currently hovering over
    NSInteger rowNumber = CGRectGetMinY(self.scrollBarLabel.frame) / 100.f;

    // Update the date on the label using the model data for that row
    // (here we assume you have a model named `Event`)
    Event *event = self.events[rowNumber];
    self.scrollBarLabel.date = event.date;
}

Subclassing UIViewController <UIScrollViewDelegate>

#pragma mark - Show/Hide the Label Using UIScrollViewDelegate Callbacks

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    [self.scrollBarLabel adjustPositionForScrollView:scrollView];
    [self.scrollBarLabel setDisplayed:YES animated:YES afterDelay:0.0f];
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
    [self.scrollBarLabel setDisplayed:NO animated:YES afterDelay:self.scrollBarFadeDelay];
}

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView
                  willDecelerate:(BOOL)decelerate {
    if (!decelerate) {
        [self.scrollBarLabel setDisplayed:NO animated:YES afterDelay:self.scrollBarFadeDelay];
    }
}

- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView {
    [self.scrollBarLabel setDisplayed:NO animated:YES afterDelay:self.scrollBarFadeDelay];
}

- (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView {
    [self.scrollBarLabel setDisplayed:NO animated:YES afterDelay:self.scrollBarFadeDelay];
}

License

MIT license. See the LICENSE file for details.

More Repositories

1

MDCSwipeToChoose

Swipe to "like" or "dislike" any view, just like Tinder.app. Build a flashcard app, a photo viewer, and more, in minutes, not hours!
Objective-C
2,552
star
2

MDCParallaxView

Create a parallax effect using a custom container view, much like the top view of Path's timeline.
Objective-C
795
star
3

Gift

Swift bindings to libgit2. But you should use https://github.com/SwiftGit2/SwiftGit2 instead!
Swift
251
star
4

django-generate-scaffold

Generate a Django model, views, URLconf, and templates using a single command.
Python
141
star
5

MDCFocusView

Apply a "tutorial screen" overlay to your application window.
Objective-C
119
star
6

gory

Factories for your Go structs. Think factory_girl.
Go
87
star
7

MDCShineEffect

Add a "shine" effect to any view.
Objective-C
62
star
8

LLVMPlayground

Small sample programs that use LLVM and Clang APIs.
C++
51
star
9

signatures

API Server with 90%+ Test Coverage in 260 Lines of Code
Go
44
star
10

MDCDamerauLevenshtein

Calculate the edit distance between NSString objects.
Objective-C
36
star
11

github-recommendation-engine

Discover repositories you should be following on Github.
Python
30
star
12

XCTest-Headers

class-dump meets XCTest.framework.
Objective-C
23
star
13

stackoverflow-fanatic

Automate your way to two Stack Exchange badges.
Shell
23
star
14

Guanaco

Nimble matchers for LlamaKit.
Swift
22
star
15

pyhoe

Python project skeleton
JavaScript
14
star
16

GitHubViewer

Sample app for #ios_startup lightning talk.
Objective-C
14
star
17

state_machine_rspec

Custom matchers for pluginaweek/state_machine.
Ruby
13
star
18

UIKit-Class-Dump

class-dump meets UIKit.framework.
Objective-C
12
star
19

glorious

Finds SenTestingKit or XCTest Mach-O files and class-dumps them.
Ruby
8
star
20

MotivationalCode

A collection of motivational programs.
Objective-C
6
star
21

move.vim

Vim configuration for the Move programming language.
Vim Script
6
star
22

llvm-scripts

Scripts I use during LLVM development.
Shell
5
star
23

ClassDumpFormatter.swift

A poor reimplementation of `class-dump -H`.
Swift
4
star
24

dotfiles

Vim Script
4
star
25

OCUnit

A mirror of OCUnitHome v41.
Objective-C
4
star
26

XCTest.swift

The headers generated for XCTest.framework by the Swift compiler
Swift
3
star
27

dotvim

my vim setup
Vim Script
3
star
28

UIView-MDCBlink

HTML <blink></blink> for iOS. Inspired by https://github.com/gekitz/GKSlidingText
Objective-C
3
star
29

android-first-twitter-app

https://github.com/sassy/iOSFirstTwitterAppのアンドロイド版
3
star
30

FoosballTimer

Sample app with RubyMotion
Ruby
2
star
31

foosball-timer-android

Timebox your Foosball games with this terrible beginner Android app.
2
star
32

MDCQuickSelect

Categories to quickly select the "n-th most" element, or the "n most" elements in an array.
Objective-C
2
star
33

UIView-MDCTapBack

Record taps and execute tap callbacks on any instance of UIView.
Objective-C
2
star
34

MTBlockTableView

An iOS Table View that uses block-based delegation instead of protocols.
Objective-C
1
star
35

modocachejp

Small blog on heroku.
Python
1
star
36

asciidoc-manning-templates

Custom Asciidoc templates for producing Docbook suitable for submission as Manning manuscripts
1
star
37

cargo

CLRS data structures and algorithms in Go.
Go
1
star
38

Kiwi-Project-Templates

Xcode Project Templates for the Kiwi BDD Framework.
Objective-C
1
star
39

KIFSpecs

An unofficial repository of CocoaPods (cocoapods.org) specifications for users of KIF.
Ruby
1
star
40

MBSpacialViewController

Create an arbitrarily complex map of view controllers in 2D space.
Objective-C
1
star