• Stars
    star
    293
  • Rank 141,748 (Top 3 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created almost 11 years ago
  • Updated about 10 years ago

Reviews

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

Repository Details

"Twitter music" and "Yahoo! Weather" like pull-to-refresh control created using GIF.

CHGifRefreshControl

"Twitter music" and "Yahoo! Weather" like pull-to-refresh control created using GIF.

Completely created using UIKit framework.

Easy to drop into your project.

You can add your favorite gif animation to your own project, CHGifRefreshControl make it super easy.

Requirements

CHGifRefreshControl requires Xcode 5, targeting either iOS 5.0 and above, ARC-enabled.

How to use

Drag UIScrollView+GifPullToRefresh.h amd UIScrollView+GifPullToRefresh.m files to your project.

No other frameworks required.

#import "UIScrollView+GifPullToRefresh.h"

UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
    
NSMutableArray *TwitterMusicDrawingImgs = [NSMutableArray array];
NSMutableArray *TwitterMusicLoadingImgs = [NSMutableArray array];
for (NSUInteger i  = 0; i <= 73; i++) {
    NSString *fileName = [NSString stringWithFormat:@"PullToRefresh_%03d.png",i];
    [TwitterMusicDrawingImgs addObject:[UIImage imageNamed:fileName]];
}

for (NSUInteger i  = 73; i <= 140; i++) {
    NSString *fileName = [NSString stringWithFormat:@"PullToRefresh_%03d.png",i];
    [TwitterMusicLoadingImgs addObject:[UIImage imageNamed:fileName]];
}
__weak UIScrollView *tempScrollView = scrollView;
[scrollView addPullToRefreshWithDrawingImgs:TwitterMusicDrawingImgs andLoadingImgs:TwitterMusicLoadingImgs andActionHandler:^{
	//Do your own work when refreshing, and don't forget to end the animation after work finished.
    [tempScrollView performSelector:@selector(didFinishPullToRefresh) withObject:nil afterDelay:3];

}];

And do not forget to remove it in your viewController's dealloc method:

[scrollView removePullToRefresh];

Tips

You can use convert command to convert all your gif picture's frames into png pictures:

convert -coalesce animation.gif animation.png

Make sure to install ImageMagick and ghostscript first, you can use brew to simplify process:

brew install imagemagick
brew install ghostscript

How it looks

![CHGifRefreshControl] (https://raw.github.com/cyndibaby905/GIFRefreshControl/master/TwitterMusic.gif) ![CHGifRefreshControl] (https://raw.github.com/cyndibaby905/GIFRefreshControl/master/YahooWeather.gif) ![CHGifRefreshControl] (https://raw.github.com/cyndibaby905/GIFRefreshControl/master/Chrome.gif) ![CHGifRefreshControl] (https://raw.github.com/cyndibaby905/GIFRefreshControl/master/Universe.gif) ![CHGifRefreshControl] (https://raw.github.com/cyndibaby905/GIFRefreshControl/master/MacOSX.gif) ![CHGifRefreshControl] (https://raw.github.com/cyndibaby905/GIFRefreshControl/master/Windows.gif)

Known issues

CHGifRefreshControl assumes the scrollView's contentInset is UIEdgeInsetsMake(64.0f, 0.0f, 0.0f, 0.0f) in iOS 7 and UIEdgeInsetsMake(0.0f, 0.0f, 0.0f, 0.0f) in iOS 6. If this doesn't work for your project, you can modify the originalContentInsectY property in CHGifRefreshControl class. And I will make this step automatically later.

Lincense

CHGifRefreshControl is available under the MIT license. See the LICENSE file for more info.

More Repositories

1

TwitterCover

TwitterCover is a parallax top view with real time blur effect to any UIScrollView, inspired by Twitter for iOS.
Objective-C
1,164
star
2

TumblrMenu

Tumblr iOS app like menu view completely created using core animation.
Objective-C
426
star
3

TwitterCover-Android

The Android version of https://github.com/cyndibaby905/TwitterCover
Java
404
star
4

CHAnimation

CHAnimation is a project used to demonstrate how to write your own animation engine, inspired by Facebook Pop.
Objective-C
368
star
5

flutter_core_demo

本仓库包含了极客时间专栏《Flutter核心技术与实战》的全部代码示例
261
star
6

13_listview_demo

Dart
16
star
7

11_Flutter_lifecycle

Dart
14
star
8

08_Dart_Sample

A Dart Sample
Dart
13
star
9

31_flutter_push_plugin

Dart
9
star
10

30_provider_demo

Dart
7
star
11

44_flutter_module_demo

Dart
7
star
12

20_data_transfer

Dart
7
star
13

27_native_view

Dart
6
star
14

34_multi_env

Dart
6
star
15

19_gesture_demo

Dart
6
star
16

39_crashy_demo

Dart
5
star
17

22_app_animation

Dart
5
star
18

15_custom_ui_demo

Dart
5
star
19

28_module_page

Dart
5
star
20

40_peformance_demo

Dart
5
star
21

Translator

A translator using YQL
Python
4
star
22

23_dart_async

Dart
4
star
23

21_router_demo

Dart
3
star
24

Translator_android

Translator for android
Python
3
star
25

44_flutter_plugin_network

Dart
3
star
26

39_flutter_crash_plugin

Dart
2
star
27

25_data_persistence

Dart
2
star
28

28_iOSDemo

Objective-C
2
star
29

28_AndroidDemo

Java
2
star
30

44_iOSDemo

Objective-C
2
star
31

31_flutter_push_demo

Dart
2
star
32

44_AndroidDemo

Java
2
star
33

26_native_method

Dart
1
star
34

32_i18n_demo

Dart
1
star
35

33_multi_screen_demo

Dart
1
star
36

29_flutter_module_page

Dart
1
star
37

29_android_hybrid_demo

Java
1
star
38

38_test_app

Dart
1
star
39

29_ios_hybrid_demo

Objective-C
1
star