Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# OS X folder attributes
.DS_Store

# user-specific XCode stuff
# user-specific Xcode stuff
*.mode1v3
*.mode2v3
*.pbxuser
*.perspectivev3
*.xcuserdatad
*.xcuserdatad
Binary file added Demo/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 35 additions & 5 deletions Demo/ODRefreshControlDemo.xcodeproj/project.pbxproj
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
0116444A1BC2204600C21BC9 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 011644491BC2204600C21BC9 /* [email protected] */; settings = {ASSET_TAGS = (); }; };
E5013A2115A43A940035F4A0 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E5013A2015A43A940035F4A0 /* UIKit.framework */; };
E5013A2315A43A940035F4A0 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E5013A2215A43A940035F4A0 /* Foundation.framework */; };
E5013A2515A43A940035F4A0 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E5013A2415A43A940035F4A0 /* CoreGraphics.framework */; };
Expand All @@ -19,6 +20,7 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
011644491BC2204600C21BC9 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
E5013A1C15A43A940035F4A0 /* ODRefreshControlDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ODRefreshControlDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
E5013A2015A43A940035F4A0 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
E5013A2215A43A940035F4A0 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -54,6 +56,7 @@
E5013A1115A43A930035F4A0 = {
isa = PBXGroup;
children = (
011644491BC2204600C21BC9 /* [email protected] */,
E5013A2615A43A940035F4A0 /* ODRefreshControlDemo */,
E5013A1F15A43A940035F4A0 /* Frameworks */,
E5013A1D15A43A940035F4A0 /* Products */,
Expand Down Expand Up @@ -139,7 +142,7 @@
E5013A1315A43A930035F4A0 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0430;
LastUpgradeCheck = 0700;
};
buildConfigurationList = E5013A1615A43A930035F4A0 /* Build configuration list for PBXProject "ODRefreshControlDemo" */;
compatibilityVersion = "Xcode 3.2";
Expand All @@ -164,6 +167,7 @@
buildActionMask = 2147483647;
files = (
E5013A2B15A43A940035F4A0 /* InfoPlist.strings in Resources */,
0116444A1BC2204600C21BC9 /* [email protected] in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -199,23 +203,36 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 5.1;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
};
Expand All @@ -225,14 +242,25 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 5.1;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
Expand All @@ -248,7 +276,8 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "ODRefreshControlDemo/ODRefreshControlDemo-Prefix.pch";
INFOPLIST_FILE = "ODRefreshControlDemo/ODRefreshControlDemo-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 4.0;
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
PRODUCT_BUNDLE_IDENTIFIER = "com.orangeinaday.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
Expand All @@ -260,7 +289,8 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "ODRefreshControlDemo/ODRefreshControlDemo-Prefix.pch";
INFOPLIST_FILE = "ODRefreshControlDemo/ODRefreshControlDemo-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 4.0;
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
PRODUCT_BUNDLE_IDENTIFIER = "com.orangeinaday.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
Expand Down
Empty file.
Empty file modified Demo/ODRefreshControlDemo/AppDelegate.h
100644 → 100755
Empty file.
Empty file modified Demo/ODRefreshControlDemo/AppDelegate.m
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion Demo/ODRefreshControlDemo/ODRefreshControlDemo-Info.plist
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.orangeinaday.${PRODUCT_NAME:rfc1034identifier}</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
Empty file modified Demo/ODRefreshControlDemo/ODRefreshControlDemo-Prefix.pch
100644 → 100755
Empty file.
Empty file modified Demo/ODRefreshControlDemo/ViewController.h
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion Demo/ODRefreshControlDemo/ViewController.m
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface

- (void)dropViewDidBeginRefreshing:(ODRefreshControl *)refreshControl
{
double delayInSeconds = 3.0;
double delayInSeconds = 1.5;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[refreshControl endRefreshing];
Expand Down
Empty file modified Demo/ODRefreshControlDemo/en.lproj/InfoPlist.strings
100644 → 100755
Empty file.
Empty file modified Demo/ODRefreshControlDemo/main.m
100644 → 100755
Empty file.
13 changes: 6 additions & 7 deletions ODRefreshControl.podspec
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
Pod::Spec.new do |s|
s.name = 'ODRefreshControl'
s.version = '1.2'
s.version = '0.1'
s.license = 'MIT'
s.summary = "A pull down to refresh control like the one in Apple's iOS6 Mail App."
s.homepage = 'https://github.com/Sephiroth87/ODRefreshControl'
s.author = { 'Fabio Ritrovato' => 'fabio@orangeinaday.com' }
s.source = { :git => 'https://github.com/Sephiroth87/ODRefreshControl.git', :tag => '1.2' }
s.summary = "水滴型下拉刷新控件(A pull down to refresh control like water dropped)."
s.homepage = 'https://github.com/wolfcon/ODRefreshControl'
s.author = { 'Frank(fork from Fabio Ritrovato)' => '472730949@qq.com' }
s.source = { :git => 'https://github.com/wolfcon/ODRefreshControl.git', :tag => '0.1' }

s.description = 'ODRefreshControl is a "pull down to refresh" control for UIScrollView,' \
'like the one Apple introduced in iOS6, but available to anyone from iOS4 and up.'
s.description = '水滴型下拉刷新控件(A pull down to refresh control like water dropped).'
s.platform = :ios

s.source_files = 'ODRefreshControl/ODRefreshControl*.{h,m}'
Expand Down
3 changes: 3 additions & 0 deletions ODRefreshControl/ODRefreshControl.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,18 @@
}

@property (nonatomic, readonly, getter=isRefreshing) BOOL refreshing;
@property (nonatomic, assign) CGFloat finishedLabelShownInterval; // default 0.5s //默认0.5秒

#ifdef __IPHONE_5_0
@property (nonatomic, strong) UIColor *tintColor UI_APPEARANCE_SELECTOR;
@property (nonatomic, assign) UIActivityIndicatorViewStyle activityIndicatorViewStyle UI_APPEARANCE_SELECTOR;
@property (nonatomic, strong) UIColor *activityIndicatorViewColor UI_APPEARANCE_SELECTOR; // iOS5 or more
@property (nonatomic, strong) UILabel *finishedLabel UI_APPEARANCE_SELECTOR;
#else
@property (nonatomic, strong) UIColor *tintColor;
@property (nonatomic, assign) UIActivityIndicatorViewStyle activityIndicatorViewStyle;
@property (nonatomic, strong) UIColor *activityIndicatorViewColor; // iOS5 or more
@property (nonatomic, strong) UILabel *finishedLabel;
#endif

- (id)initInScrollView:(UIScrollView *)scrollView;
Expand Down
80 changes: 51 additions & 29 deletions ODRefreshControl/ODRefreshControl.m
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
//
// https://github.com/Sephiroth87/ODRefreshControl
//
//
// Change by Frank on 10/7/15
// Add finished Label.
//

#import "ODRefreshControl.h"

Expand Down Expand Up @@ -36,12 +40,6 @@ @interface ODRefreshControl ()

@implementation ODRefreshControl

@synthesize refreshing = _refreshing;
@synthesize tintColor = _tintColor;

@synthesize scrollView = _scrollView;
@synthesize originalContentInset = _originalContentInset;

static inline CGFloat lerp(CGFloat a, CGFloat b, CGFloat p)
{
return a + (b - a) * p;
Expand All @@ -65,14 +63,23 @@ - (id)initInScrollView:(UIScrollView *)scrollView activityIndicatorView:(UIView
[scrollView addObserver:self forKeyPath:@"contentInset" options:NSKeyValueObservingOptionNew context:nil];

_activity = activity ? activity : [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
_activity.center = CGPointMake(floor(self.frame.size.width / 2), floor(self.frame.size.height / 2));
_activity.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
_activity.alpha = 0;
if ([_activity respondsToSelector:@selector(startAnimating)]) {
[(UIActivityIndicatorView *)_activity startAnimating];
}
[self addSubview:_activity];

//add the label "Finished"
_finishedLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 300, 44)];
_finishedLabel.textAlignment = NSTextAlignmentCenter;
_finishedLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
_finishedLabel.alpha = 0;
_finishedLabel.text = @"✔️ Finished!";
_finishedLabel.font = [UIFont systemFontOfSize:[UIFont systemFontSize]];
[self addSubview:_finishedLabel];
_finishedLabelShownInterval = 0.5;

_refreshing = NO;
_canRefresh = YES;
_ignoreInset = NO;
Expand Down Expand Up @@ -188,7 +195,9 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
_shapeLayer.position = CGPointMake(0, kMaxDistance + offset + kOpenedViewHeight);
[CATransaction commit];

_activity.center = CGPointMake(floor(self.frame.size.width / 2), MIN(offset + self.frame.size.height + floor(kOpenedViewHeight / 2), self.frame.size.height - kOpenedViewHeight/ 2));
CGPoint center = CGPointMake(floor(self.frame.size.width / 2), MIN(offset + self.frame.size.height + floor(kOpenedViewHeight / 2), self.frame.size.height - kOpenedViewHeight/ 2));
_activity.center = center;
_finishedLabel.center = center;

_ignoreInset = YES;
_ignoreOffset = YES;
Expand Down Expand Up @@ -409,6 +418,7 @@ - (void)beginRefreshing

_activity.alpha = 1;
_activity.layer.transform = CATransform3DMakeScale(1, 1, 1);
_finishedLabel.alpha = 1;

CGPoint offset = self.scrollView.contentOffset;
_ignoreInset = YES;
Expand All @@ -429,28 +439,40 @@ - (void)endRefreshing
// halfway through the end animation.
// This allows for the refresh control to clean up the observer,
// in the case the scrollView is released while the animation is running

// show finished label
// 显示完成标签
_finishedLabel.alpha = 1;
_activity.alpha = 0;
_activity.layer.transform = CATransform3DMakeScale(0.1, 0.1, 1);

__block UIScrollView *blockScrollView = self.scrollView;
[UIView animateWithDuration:0.4 animations:^{
_ignoreInset = YES;
[blockScrollView setContentInset:self.originalContentInset];
_ignoreInset = NO;
_activity.alpha = 0;
_activity.layer.transform = CATransform3DMakeScale(0.1, 0.1, 1);
} completion:^(BOOL finished) {
[_shapeLayer removeAllAnimations];
_shapeLayer.path = nil;
_shapeLayer.shadowPath = nil;
_shapeLayer.position = CGPointZero;
[_arrowLayer removeAllAnimations];
_arrowLayer.path = nil;
[_highlightLayer removeAllAnimations];
_highlightLayer.path = nil;
// We need to use the scrollView somehow in the end block,
// or it'll get released in the animation block.
_ignoreInset = YES;
[blockScrollView setContentInset:self.originalContentInset];
_ignoreInset = NO;
}];

// default delay 0.5s show finished label;
// 默认延迟0.5s用来显示完成标签
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(_finishedLabelShownInterval * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[UIView animateWithDuration:0.4 animations:^{
_ignoreInset = YES;
[blockScrollView setContentInset:self.originalContentInset];
_ignoreInset = NO;

_finishedLabel.alpha = 0;
} completion:^(BOOL finished) {
[_shapeLayer removeAllAnimations];
_shapeLayer.path = nil;
_shapeLayer.shadowPath = nil;
_shapeLayer.position = CGPointZero;
[_arrowLayer removeAllAnimations];
_arrowLayer.path = nil;
[_highlightLayer removeAllAnimations];
_highlightLayer.path = nil;
// We need to use the scrollView somehow in the end block,
// or it'll get released in the animation block.
_ignoreInset = YES;
[blockScrollView setContentInset:self.originalContentInset];
_ignoreInset = NO;
}];
});
}
}

Expand Down
Loading