GithubHelp home page GithubHelp logo

kb100824 / pulltorefreshcoretext Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cemolcay/pulltorefreshcoretext

0.0 2.0 0.0 417 KB

PullToRefresh extension for all UIScrollView type classes with animated text drawing style

License: MIT License

Ruby 20.80% Objective-C 79.20%

pulltorefreshcoretext's Introduction

PullToRefreshCoreText

PullToRefresh extension for all UIScrollView type classes with animated text drawing style

Demo

alt tag

Install

Manual
Copy the files in the folder named PullToRefreshCoreText to your project.
Import the "UIScrollView+PullToRefreshCoreText.h"

Cocoapods

    source 'https://github.com/CocoaPods/Specs.git'
    pod 'PullToRefreshCoreText', '~> 0.2'

Usage

- (void)addPullToRefreshWithPullText:(NSString *)pullText
                       pullTextColor:(UIColor *)pullTextColor
                        pullTextFont:(UIFont *)pullTextFont
                      refreshingText:(NSString *)refreshingText
                 refreshingTextColor:(UIColor *)refreshingTextColor
                  refreshingTextFont:(UIFont *)refreshingTextFont
                              action:(pullToRefreshAction)action;

It has 2 main texts, pulling and refreshing.
Init function has parameters for creating this texts with its strings, text colors and fonts.
Last parameter is the block function where loading code goes to.

Alternatively I added some other init methods if you want to use same texts or fonts etc.

   - (void)addPullToRefreshWithPullText:(NSString *)pullText
                                 action:(pullToRefreshAction)action;
   
   - (void)addPullToRefreshWithPullText:(NSString *)pullText
                         refreshingText:(NSString *)refreshingText
                                 action:(pullToRefreshAction)action;
   
   - (void)addPullToRefreshWithPullText:(NSString *)pullText
                                   font:(UIFont *)font
                                 action:(pullToRefreshAction)action;
   
   
   - (void)addPullToRefreshWithPullText:(NSString *)pullText
                         refreshingText:(NSString *)refreshingText
                                   font:(UIFont *)font
                                 action:(pullToRefreshAction)action;
   
   
   - (void)addPullToRefreshWithPullText:(NSString *)pullText
                          pullTextColor:(UIColor *)pullTextColor
                         refreshingText:(NSString *)refreshingText
                    refreshingTextColor:(UIColor *)refreshingTextColor
                                   font:(UIFont *)font
                                 action:(pullToRefreshAction)action;

Implementation

//Create ScrollView
self.scrollView = [[UIScrollView alloc] initWithFrame:self.view.frame];
[self.scrollView setContentSize:CGSizeMake(self.view.frame.size.width, self.scrollView.frame.size.height + 1)];
[self.view addSubview:self.scrollView];


//add pull to refresh
__weak typeof(self) weakSelf = self;
[self.scrollView addPullToRefreshWithPullText:@"Pull To Refresh" pullTextColor:[UIColor blackColor] pullTextFont:DefaultTextFont refreshingText:@"Refreshing" refreshingTextColor:[UIColor blueColor] refreshingTextFont:DefaultTextFont action:^{
    [weakSelf loadItems];
}];

One last thing: you should call the [scrollView finishLoading] method after the load finishes.
Otherwise you stuck in refreshing state always.

Credits

Blogs and codes I used for creating this
https://github.com/jrturton/NSString-Glyphs
http://www.codeproject.com/Articles/109729/Low-level-text-rendering
http://ronnqvi.st/controlling-animation-timing/

pulltorefreshcoretext's People

Contributors

cemolcay avatar neonichu avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.