• Stars
    star
    103
  • Rank 333,046 (Top 7 %)
  • Language
    Objective-C
  • License
    Apache License 2.0
  • Created about 11 years ago
  • Updated almost 8 years ago

Reviews

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

Repository Details

ITPullToRefreshScrollView is a subclass of `NSScrollView` with iOS 7 style refreshing

ITPullToRefreshScrollView

ITPullToRefreshScrollView is a subclass of NSScrollView which allows iOS 7 style refreshing by pulling. ITPullToRefreshScrollView was created for Play by Play, development funded by David Keegan.

Thanks to

Usage

Include files in project

ITPullToRefreshScrollView has two submodules. You need to copy the following files:

Files under /ITPullToRefreshScrollView/Classes/

  • ITPullToRefreshScrollView.h
  • ITPullToRefreshScrollView.m
  • ITPullToRefreshClipView.h
  • ITPullToRefreshClipView.m
  • ITPullToRefreshEdgeView.h
  • ITPullToRefreshEdgeView.m
  • DuxScrollViewAnimation.h
  • DuxScrollViewAnimation.m

Files under /Modules/ITProgressIndicator/ITProgressIndicator/Classes/

  • ITProgressIndicator.h
  • ITProgressIndicator.m
  • NSBezierPath+Geometry.h
  • NSBezierPath+Geometry.m

Files under /Modules/NSBKeyframeAnimation/NSBKeyframeAnimation/Classes/NSBKeyframeAnimation/

  • NSBKeyframeAnimation.h
  • NSBKeyframeAnimation.m
  • NSBKeyframeAnimationFunctions.h
  • NSBKeyframeAnimationFunctions.c

Make sure to copy them to the project, and to add them to the target.

Use in a project

Make sure to check out the sample project.

Set the custom class of your scroll view in Interface Builder to ITPullToRefreshScrollView. Next you need to connect a IBOutlet to your scroll view.

@property (assign) IBOutlet ITPullToRefreshScrollView *scrollView;

Then you can configure in code, which edges of the scroll view should be refreshable.

// Make top & bottom refreshable
self.scrollView.refreshableEdges = ITPullToRefreshEdgeTop | ITPullToRefreshEdgeBottom;

To receive notifications from the scroll view, you need to create a delegate. To do this, your delegate class must implement the ITPullToRefreshScrollViewDelegate protocol. You can then implement the following methods.

/**
 *  This method get's invoked when the scroll view started refreshing
 *
 *  @param scrollView - The scroll view that started refreshing
 *  @param edge       - The edge that started refreshing
 */
- (void)pullToRefreshView:(ITPullToRefreshScrollView *)scrollView
   didStartRefreshingEdge:(ITPullToRefreshEdge)edge {

  // Do stuff that takes very long
  
  // Don't forget to call this line!
  [scrollView stopRefreshingEdge:edge];
}

/**
 *  This method get's invoked when the scroll view stopped refreshing
 *
 *  @param scrollView - The scroll view that stopped refreshing
 *  @param edge       - The edge that stopped refreshing
 */
- (void)pullToRefreshView:(ITPullToRefreshScrollView *)scrollView
    didStopRefreshingEdge:(ITPullToRefreshEdge)edge {

  // Do UI stuff
}

To receive notifications, you finally have to set the delegate of the scroll view.

self.scrollView.delegate = self;

Customisation

To create custom ITPullToRefreshEdgeView subclasses, override the following methods:

// --------------------------
// ------------------- Events
// --------------------------

/**
 *  This method is called when the edge is triggered
 *
 *  @param scrollView - The sender scroll view
 */
- (void)pullToRefreshScrollViewDidTriggerRefresh:(ITPullToRefreshScrollView *)scrollView;

/**
 *  This method is called when the edge is untriggered
 *
 *  @param scrollView - The sender scroll view
 */
- (void)pullToRefreshScrollViewDidUntriggerRefresh:(ITPullToRefreshScrollView *)scrollView;

/**
 *  This method is called when the edge starts refreshing
 *
 *  @param scrollView - The sender scroll view
 */
- (void)pullToRefreshScrollViewDidStartRefreshing:(ITPullToRefreshScrollView *)scrollView;

/**
 *  This method is called when the edge stops refreshing
 *
 *  @param scrollView - The sender scroll view
 */
- (void)pullToRefreshScrollViewDidStopRefreshing:(ITPullToRefreshScrollView *)scrollView;

/**
 *  This method is called when part of the edge view becomes visible
 *
 *  @param scrollView - The sender scroll view
 *  @param progress   - The amount of the edge view that is visible (from 0.0 to 1.0)
 */
- (void)pullToRefreshScrollView:(ITPullToRefreshScrollView *)scrollView didScrollWithProgress:(CGFloat)progress;



// --------------------------
// ------------ Customisation
// --------------------------

/**
 *  Override this to remove the progress indicator and create other components
 */
- (void)installComponents;

/**
 *  The height of the edge view.
 *  Override this method to achieve a custom edge view height.
 *
 *  @return The height of the edge view
 */
- (CGFloat)edgeViewHeight;

/**
 *  Override this method to draw a custom background.
 *  You can also just override `drawRect:` and to all the drawing on your own.
 *
 *  @param The rect which should be drawn on
 */
- (void)drawBackgroundInRect:(NSRect)dirtyRect;

More Repositories

1

ITSwitch

ITSwitch is a replica of UISwitch for Mac OS X
Objective-C
290
star
2

ITSidebar

ITSidebar is a control for Mac OS X similar to the one of Sparrow
Objective-C
267
star
3

Pathfinder

A pathfinding library written in Swift
Swift
153
star
4

Pathbar

ITPathbar is a NSPathControl subclass, with a custom design.
Objective-C
130
star
5

ITProgressIndicator

A replacement class for `NSProgressIndicator` driven by Core Animation
Objective-C
117
star
6

ITProgressBar

ITProgressBar is a very lightweight progress bar replacement for Mac OS X
Objective-C
81
star
7

ITProgressBar-iOS

ITProgressBar is a simple iOS 7 style progress bar control.
Objective-C
46
star
8

ITSearchField

ITSearchField is a subclass of NSSearchField, which can collapse and expand if you click the search icon.
Objective-C
39
star
9

Conway-s-Game-of-Life

Conway's Game of Life written in Swift
Swift
36
star
10

ITNavigationView

A iOS like view driven by Core Animation, that can replace it's subview with a sleek animation
Objective-C
32
star
11

ITActivityIndicator

A very simple alternative to UIActivityIndicatorView
Swift
21
star
12

ITTransitionView

A port of ADTransitionController to Mac OS X
Objective-C
14
star
13

ITShortcutReader

Objective-C
9
star
14

2048

A clone of 2048 written with Cocos2d in Swift
Objective-C
6
star
15

Super-Mario-Bros

A super buggy version of Super Mario Bros. for iOS
Objective-C
5
star
16

Tetris

A simple Tetris game written in Swift
Swift
5
star
17

ViewControllerTest

Small NSViewController test for a question on Stackoverflow
Objective-C
4
star
18

zmk-config

Makefile
1
star
19

php-typealias-rfc

1
star
20

php-benchmark-data

1
star