Latest 1.0.0
Homepage https://github.com/stonezhl/STNScrollBarControl
License MIT
Platforms ios 8.0
Authors

A scroll bar like Google photo’s can scroll scrollview/tableview/collectionview and show text depending on cell

Demo

STNScrollBarControl

Who need this?

When you have a large list of cells in tableview or collectionview, sectionIndexTitlesForTableView is not enough.

Requirements

  • Objective-C
  • iOS 8.0+
  • ARC

How to use it?

  1. Add property
    @property (strong, nonatomic) STNScrollBar *scrollBar;
  2. Create instance
    self.scrollBar = [STNScrollBar scrollBar];
    self.scrollBar.scrollView = self.tableView;
    self.scrollBar.delegate = self;
  3. Add view
    • TableView/CollectionView in UIViewController
      [self.view addSubview:self.scrollBar];
    • TableViewController/CollectionViewController in NavigationController
      [self.navigationController.view addSubview:self.scrollBar];
  4. Add viewDidDisappear
    - (void)viewDidDisappear:(BOOL)animated {
       [self.scrollBar viewDidDisappear];
    }
  5. Add UIScrollViewDelegate

    - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
       [self.scrollBar scrollViewWillBeginDragging];
    }
    
    - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
       [self.scrollBar scrollViewDidScroll];
    }
    
    - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
       [self.scrollBar scrollViewDidEndDraggingAndWillDecelerate:decelerate];
    }
    
    - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
       [self.scrollBar scrollViewDidEndDecelerating];
    }
  6. Add STNScrollBarDelegate
    - (NSString *)scrollBar:(STNScrollBar *)scrollBar itemStringAtIndexPath:(NSIndexPath *)indexPath {
       return self.names[indexPath.row]; // anything you want to show based on indexPath
    }

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate STNScrollBarControl into your Xcode project using CocoaPods, specify it to a target in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'

target 'MyApp' do
  # your other pod
  # ...
  pod 'STNScrollBarControl', '~> 1.0'
end

Then, run the following command:

$ pod install

You should open the {Project}.xcworkspace instead of the {Project}.xcodeproj after you installed anything from CocoaPods.

For more information about how to use CocoaPods, I suggest this tutorial.

License

STNScrollBarControl is released under the MIT license. See LICENSE for details.

Latest podspec

{
    "name": "STNScrollBarControl",
    "version": "1.0.0",
    "summary": "A scroll bar like Google photo's can scroll scrollview/tableview/collectionview and show text depending on cell",
    "description": "The scroll bar is subclass of UIControl and it is very easly added to scrollview/tableview/collectionview. It also can show text when implement delegate.",
    "homepage": "https://github.com/stonezhl/STNScrollBarControl",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Stone Zhang": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/stonezhl/STNScrollBarControl.git",
        "tag": "1.0.0"
    },
    "source_files": [
        "STNScrollBarControl",
        "STNScrollBarControl/**/*.{h,m,swift}"
    ]
}

Pin It on Pinterest

Share This