├── .gitignore ├── AAPullToRefresh.podspec ├── AAPullToRefresh ├── AAPullToRefresh.h ├── AAPullToRefresh.m ├── centerIcon@2x.png └── launchpad@2x.png ├── AAPullToRefreshDemo ├── AAPullToRefreshDemo.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── AAPullToRefreshDemo │ ├── AAPullToRefreshDemo-Info.plist │ ├── AAPullToRefreshDemo-Prefix.pch │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Base.lproj │ │ ├── Main_iPad.storyboard │ │ └── Main_iPhone.storyboard │ ├── Images.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ └── LaunchImage.launchimage │ │ │ └── Contents.json │ ├── LaunchScreen.xib │ ├── ViewController.h │ ├── ViewController.m │ ├── en.lproj │ │ └── InfoPlist.strings │ └── main.m └── AAPullToRefreshDemoTests │ ├── AAPullToRefreshDemoTests-Info.plist │ ├── AAPullToRefreshDemoTests.m │ └── en.lproj │ └── InfoPlist.strings ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | .DS_Store 3 | */build/* 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | profile 14 | *.moved-aside 15 | DerivedData 16 | .idea/ 17 | *.hmap 18 | *.xccheckout 19 | 20 | #CocoaPods 21 | Pods 22 | -------------------------------------------------------------------------------- /AAPullToRefresh.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "AAPullToRefresh" 3 | s.version = "1.0.2" 4 | s.summary = "All around pull to refresh library." 5 | s.homepage = "https://github.com/r-plus/AAPullToRefresh/" 6 | s.license = 'MIT' 7 | s.author = { "r-plus" => "anasthasia.r@gmail.com" } 8 | s.source = { :git => "https://github.com/r-plus/AAPullToRefresh.git", :tag => s.version.to_s } 9 | s.platform = :ios, '6.0' 10 | s.source_files = 'AAPullToRefresh' 11 | s.requires_arc = true 12 | end 13 | -------------------------------------------------------------------------------- /AAPullToRefresh/AAPullToRefresh.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | typedef void (^actionHandler)(void); 4 | typedef NS_ENUM(NSUInteger, AAPullToRefreshState) { 5 | AAPullToRefreshStateNormal = 0, 6 | AAPullToRefreshStateStopped, 7 | AAPullToRefreshStateLoading, 8 | }; 9 | typedef NS_ENUM(NSUInteger, AAPullToRefreshPosition) { 10 | AAPullToRefreshPositionTop, 11 | AAPullToRefreshPositionBottom, 12 | AAPullToRefreshPositionLeft, 13 | AAPullToRefreshPositionRight, 14 | }; 15 | 16 | @interface AAPullToRefresh : UIView 17 | 18 | @property (nonatomic, assign) CGFloat originalInsetTop; 19 | @property (nonatomic, assign) CGFloat originalInsetBottom; 20 | @property (nonatomic, assign, readonly) AAPullToRefreshPosition position; 21 | @property (nonatomic, weak) UIScrollView *scrollView; 22 | @property (nonatomic, copy) void (^pullToRefreshHandler)(AAPullToRefresh *v); 23 | @property (nonatomic, assign) BOOL isObserving; 24 | 25 | // user customizable. 26 | @property (nonatomic, assign) BOOL showPullToRefresh; 27 | @property (nonatomic, assign) CGFloat threshold; 28 | @property (nonatomic, strong) UIImage *imageIcon; 29 | @property (nonatomic, strong) UIColor *borderColor; 30 | @property (nonatomic, assign) CGFloat borderWidth; 31 | @property (nonatomic, strong) UIActivityIndicatorView *activityIndicatorView; 32 | 33 | - (id)initWithImage:(UIImage *)image position:(AAPullToRefreshPosition)position; 34 | - (void)stopIndicatorAnimation; 35 | - (void)manuallyTriggered; 36 | - (void)setSize:(CGSize)size; 37 | 38 | @end 39 | 40 | @interface UIScrollView (AAPullToRefresh) 41 | - (AAPullToRefresh *)addPullToRefreshPosition:(AAPullToRefreshPosition)position actionHandler:(void (^)(AAPullToRefresh *v))handler; 42 | @end 43 | -------------------------------------------------------------------------------- /AAPullToRefresh/AAPullToRefresh.m: -------------------------------------------------------------------------------- 1 | #import "AAPullToRefresh.h" 2 | 3 | #define DEGREES_TO_RADIANS(x) (x)/180.0*M_PI 4 | #define RADIANS_TO_DEGREES(x) (x)/M_PI*180.0 5 | 6 | @implementation UIScrollView (AAPullToRefresh) 7 | 8 | - (AAPullToRefresh *)addPullToRefreshPosition:(AAPullToRefreshPosition)position actionHandler:(void (^)(AAPullToRefresh *v))handler 9 | { 10 | // dont dupuricate add. 11 | for (UIView *v in self.subviews) { 12 | if ([v isKindOfClass:[AAPullToRefresh class]]) 13 | if (((AAPullToRefresh *)v).position == position) 14 | return (AAPullToRefresh *)v; 15 | } 16 | 17 | AAPullToRefresh *view = [[AAPullToRefresh alloc] initWithImage:[UIImage imageNamed:@"centerIcon"] 18 | position:position]; 19 | switch (view.position) { 20 | case AAPullToRefreshPositionTop: 21 | case AAPullToRefreshPositionBottom: 22 | view.frame = CGRectMake((self.bounds.size.width - view.bounds.size.width)/2, 23 | -view.bounds.size.height, view.bounds.size.width, view.bounds.size.height); 24 | break; 25 | case AAPullToRefreshPositionLeft: 26 | view.frame = CGRectMake(-view.bounds.size.width, self.bounds.size.height/2.0f, view.bounds.size.width, view.bounds.size.height); 27 | break; 28 | case AAPullToRefreshPositionRight: 29 | view.frame = CGRectMake(self.bounds.size.width, self.bounds.size.height/2.0f, view.bounds.size.width, view.bounds.size.height); 30 | break; 31 | default: 32 | break; 33 | } 34 | 35 | view.pullToRefreshHandler = handler; 36 | view.scrollView = self; 37 | view.originalInsetTop = self.contentInset.top; 38 | view.originalInsetBottom = self.contentInset.bottom; 39 | view.showPullToRefresh = YES; 40 | view.alpha = 0.0; 41 | [self addSubview:view]; 42 | 43 | return view; 44 | } 45 | @end 46 | 47 | @interface AAPullToRefreshBackgroundLayer : CALayer 48 | 49 | @property (nonatomic, assign) CGFloat outlineWidth; 50 | @property (nonatomic, assign, getter = isGlow) BOOL glow; 51 | - (id)initWithBorderWidth:(CGFloat)width; 52 | 53 | @end 54 | 55 | @implementation AAPullToRefreshBackgroundLayer 56 | 57 | - (id)initWithBorderWidth:(CGFloat)width 58 | { 59 | if ((self = [super init])) { 60 | self.outlineWidth = width; 61 | self.contentsScale = [UIScreen mainScreen].scale; 62 | self.shadowColor = [UIColor whiteColor].CGColor; 63 | self.shadowOffset = CGSizeZero; 64 | self.shadowRadius = 7.0f; 65 | self.shadowOpacity = 0.0f; 66 | [self setNeedsDisplay]; 67 | } 68 | return self; 69 | } 70 | 71 | - (void)drawInContext:(CGContextRef)ctx 72 | { 73 | //Draw white circle 74 | CGContextSetFillColor(ctx, CGColorGetComponents([UIColor colorWithWhite:1.0f alpha:0.8f].CGColor)); 75 | CGContextFillEllipseInRect(ctx,CGRectInset(self.bounds, self.outlineWidth, self.outlineWidth)); 76 | 77 | //Draw circle outline 78 | CGContextSetStrokeColorWithColor(ctx, [UIColor colorWithWhite:0.4f alpha:0.9f].CGColor); 79 | CGContextSetLineWidth(ctx, self.outlineWidth); 80 | CGContextStrokeEllipseInRect(ctx, CGRectInset(self.bounds, self.outlineWidth, self.outlineWidth)); 81 | } 82 | 83 | - (void)setOutlineWidth:(CGFloat)outlineWidth 84 | { 85 | _outlineWidth = outlineWidth; 86 | [self setNeedsDisplay]; 87 | } 88 | 89 | - (void)setGlow:(BOOL)glow 90 | { 91 | self.shadowOpacity = glow ? 1.0 : 0.0; 92 | _glow = glow; 93 | } 94 | 95 | @end 96 | 97 | /*-----------------------------------------------------------------*/ 98 | @interface AAPullToRefresh() 99 | 100 | @property (nonatomic, assign) BOOL isUserAction; 101 | @property (nonatomic, assign) AAPullToRefreshState state; 102 | @property (nonatomic, assign, readonly) BOOL isSidePosition; 103 | @property (nonatomic, strong) AAPullToRefreshBackgroundLayer *backgroundLayer; 104 | @property (nonatomic, strong) CAShapeLayer *shapeLayer; 105 | @property (nonatomic, strong) CALayer *imageLayer; 106 | @property (nonatomic, assign) double progress; 107 | @property (nonatomic, assign) double prevProgress; 108 | 109 | @end 110 | 111 | @implementation AAPullToRefresh 112 | 113 | #pragma mark - init 114 | - (id)initWithImage:(UIImage *)image position:(AAPullToRefreshPosition)position 115 | { 116 | if ((self = [super init])) { 117 | _position = position; 118 | self.imageIcon = image; 119 | [self _commonInit]; 120 | } 121 | return self; 122 | } 123 | 124 | - (void)_commonInit 125 | { 126 | self.borderColor = [UIColor colorWithRed:203/255.0 green:32/255.0 blue:39/255.0 alpha:1]; 127 | self.borderWidth = 2.0f; 128 | self.threshold = 60.0f; 129 | self.isUserAction = NO; 130 | self.contentMode = UIViewContentModeRedraw; 131 | self.state = AAPullToRefreshStateNormal; 132 | if (self.isSidePosition) 133 | self.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; 134 | else 135 | self.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin; 136 | self.backgroundColor = [UIColor clearColor]; 137 | //init actitvity indicator 138 | _activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; 139 | _activityIndicatorView.hidesWhenStopped = YES; 140 | _activityIndicatorView.frame = self.bounds; 141 | [self addSubview:_activityIndicatorView]; 142 | 143 | //init background layer 144 | AAPullToRefreshBackgroundLayer *backgroundLayer = [[AAPullToRefreshBackgroundLayer alloc] initWithBorderWidth:self.borderWidth]; 145 | backgroundLayer.frame = self.bounds; 146 | [self.layer addSublayer:backgroundLayer]; 147 | self.backgroundLayer = backgroundLayer; 148 | 149 | if (!self.imageIcon) 150 | self.imageIcon = [UIImage imageNamed:@"centerIcon"]; 151 | 152 | //init icon layer 153 | CALayer *imageLayer = [CALayer layer]; 154 | imageLayer.contentsScale = [UIScreen mainScreen].scale; 155 | imageLayer.frame = CGRectInset(self.bounds, self.borderWidth, self.borderWidth); 156 | imageLayer.contents = (id)self.imageIcon.CGImage; 157 | [self.layer addSublayer:imageLayer]; 158 | self.imageLayer = imageLayer; 159 | 160 | //init arc draw layer 161 | CAShapeLayer *shapeLayer = [[CAShapeLayer alloc] init]; 162 | shapeLayer.frame = self.bounds; 163 | shapeLayer.fillColor = nil; 164 | shapeLayer.strokeColor = self.borderColor.CGColor; 165 | shapeLayer.strokeEnd = 0.0f; 166 | shapeLayer.shadowColor = [UIColor colorWithWhite:1 alpha:0.8f].CGColor; 167 | shapeLayer.shadowOpacity = 0.7f; 168 | shapeLayer.shadowRadius = 20.0f; 169 | shapeLayer.contentsScale = [UIScreen mainScreen].scale; 170 | shapeLayer.lineWidth = self.borderWidth; 171 | shapeLayer.lineCap = kCALineCapRound; 172 | 173 | [self.layer addSublayer:shapeLayer]; 174 | self.shapeLayer = shapeLayer; 175 | } 176 | 177 | #pragma mark - layout 178 | - (void)layoutSubviews{ 179 | [super layoutSubviews]; 180 | self.shapeLayer.frame = self.bounds; 181 | [self updatePath]; 182 | } 183 | 184 | - (void)updatePath { 185 | CGPoint center = CGPointMake(CGRectGetMidX(self.bounds), CGRectGetMidY(self.bounds)); 186 | 187 | UIBezierPath *bezierPath = [UIBezierPath bezierPathWithArcCenter:center radius:(self.bounds.size.width/2.0f - self.borderWidth) startAngle:DEGREES_TO_RADIANS(-90) endAngle:DEGREES_TO_RADIANS(360-90) clockwise:YES]; 188 | 189 | self.shapeLayer.path = bezierPath.CGPath; 190 | } 191 | 192 | #pragma mark - ScrollViewInset 193 | - (void)setupScrollViewContentInsetForLoadingIndicator:(actionHandler)handler 194 | { 195 | UIEdgeInsets currentInsets = self.scrollView.contentInset; 196 | if (self.position == AAPullToRefreshPositionTop) { 197 | CGFloat offset = MAX(self.scrollView.contentOffset.y * -1, 0); 198 | currentInsets.top = MIN(offset, self.originalInsetTop + self.bounds.size.height + 20.0f); 199 | } else { 200 | //CGFloat overBottomOffsetY = self.scrollView.contentOffset.y - self.scrollView.contentSize.height + self.scrollView.frame.size.height; 201 | //currentInsets.bottom = MIN(overBottomOffsetY, self.originalInsetBottom + self.bounds.size.height + 40.0); 202 | currentInsets.bottom = MIN(self.threshold, self.originalInsetBottom + self.bounds.size.height + 40.0f); 203 | } 204 | [self setScrollViewContentInset:currentInsets handler:handler]; 205 | } 206 | 207 | - (void)resetScrollViewContentInset:(actionHandler)handler 208 | { 209 | UIEdgeInsets currentInsets = self.scrollView.contentInset; 210 | if (self.position == AAPullToRefreshPositionTop) { 211 | currentInsets.top = self.originalInsetTop; 212 | } else { 213 | currentInsets.bottom = self.originalInsetBottom; 214 | } 215 | [self setScrollViewContentInset:currentInsets handler:handler]; 216 | } 217 | 218 | - (void)setScrollViewContentInset:(UIEdgeInsets)contentInset handler:(actionHandler)handler 219 | { 220 | [UIView animateWithDuration:0.3f 221 | delay:0 222 | options:UIViewAnimationOptionAllowUserInteraction | 223 | UIViewAnimationOptionCurveEaseOut | 224 | UIViewAnimationOptionBeginFromCurrentState 225 | animations:^{ 226 | self.scrollView.contentInset = contentInset; 227 | } 228 | completion:^(BOOL finished) { 229 | if (handler) 230 | handler(); 231 | }]; 232 | } 233 | 234 | #pragma mark - property 235 | - (void)setShowPullToRefresh:(BOOL)showPullToRefresh 236 | { 237 | self.hidden = !showPullToRefresh; 238 | 239 | if (showPullToRefresh) { 240 | if (!self.isObserving) { 241 | [self.scrollView addObserver:self forKeyPath:@"contentOffset" options:NSKeyValueObservingOptionNew context:nil]; 242 | [self.scrollView addObserver:self forKeyPath:@"contentSize" options:NSKeyValueObservingOptionNew context:nil]; 243 | [self.scrollView addObserver:self forKeyPath:@"frame" options:NSKeyValueObservingOptionNew context:nil]; 244 | self.isObserving = YES; 245 | } 246 | } else { 247 | if (self.isObserving) { 248 | [self.scrollView removeObserver:self forKeyPath:@"contentOffset"]; 249 | [self.scrollView removeObserver:self forKeyPath:@"contentSize"]; 250 | [self.scrollView removeObserver:self forKeyPath:@"frame"]; 251 | self.isObserving = NO; 252 | } 253 | } 254 | } 255 | 256 | - (void)willMoveToSuperview:(UIView *)newSuperview 257 | { 258 | if (self.superview && newSuperview == nil) 259 | if (self.isObserving) 260 | self.showPullToRefresh = NO; 261 | } 262 | 263 | - (BOOL)showPullToRefresh 264 | { 265 | return !self.hidden; 266 | } 267 | 268 | - (void)setProgress:(double)progress 269 | { 270 | if (progress > 1.0) { 271 | progress = 1.0; 272 | self.backgroundLayer.glow = YES; 273 | } else { 274 | self.backgroundLayer.glow = NO; 275 | } 276 | 277 | self.alpha = 1.0 * progress; 278 | 279 | if (progress >= 0 && progress <= 1.0f) { 280 | //rotation Animation 281 | CABasicAnimation *animationImage = [CABasicAnimation animationWithKeyPath:@"transform.rotation"]; 282 | animationImage.fromValue = [NSNumber numberWithFloat:DEGREES_TO_RADIANS(180+180*self.prevProgress)]; 283 | animationImage.toValue = [NSNumber numberWithFloat:DEGREES_TO_RADIANS(180+180*progress)]; 284 | animationImage.duration = 0.1f; 285 | animationImage.removedOnCompletion = NO; 286 | animationImage.fillMode = kCAFillModeForwards; 287 | [self.imageLayer addAnimation:animationImage forKey:@"animation"]; 288 | 289 | //strokeAnimation 290 | CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; 291 | animation.fromValue = [NSNumber numberWithFloat:((CAShapeLayer *)self.shapeLayer.presentationLayer).strokeEnd]; 292 | animation.toValue = [NSNumber numberWithFloat:progress]; 293 | animation.duration = 0.1f; 294 | animation.removedOnCompletion = NO; 295 | animation.fillMode = kCAFillModeForwards; 296 | animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]; 297 | [self.shapeLayer addAnimation:animation forKey:@"animation"]; 298 | } 299 | self.prevProgress = self.progress; 300 | _progress = progress; 301 | } 302 | 303 | - (BOOL)isSidePosition 304 | { 305 | return (self.position == AAPullToRefreshPositionLeft || self.position == AAPullToRefreshPositionRight); 306 | } 307 | 308 | #pragma mark misc. 309 | - (void)setLayerOpacity:(CGFloat)opacity 310 | { 311 | self.imageLayer.opacity = opacity; 312 | self.backgroundLayer.opacity = opacity; 313 | self.shapeLayer.opacity = opacity; 314 | } 315 | 316 | - (void)setLayerHidden:(BOOL)hidden 317 | { 318 | self.imageLayer.hidden = hidden; 319 | self.shapeLayer.hidden = hidden; 320 | self.backgroundLayer.hidden = hidden; 321 | } 322 | 323 | #pragma mark - KVO 324 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context 325 | { 326 | if ([keyPath isEqualToString:@"contentOffset"]) { 327 | [self scrollViewDidScroll:[[change valueForKey:NSKeyValueChangeNewKey] CGPointValue]]; 328 | } else if ([keyPath isEqualToString:@"contentSize"]) { 329 | [self setNeedsLayout]; 330 | [self setNeedsDisplay]; 331 | } else if ([keyPath isEqualToString:@"frame"]) { 332 | [self setNeedsLayout]; 333 | [self setNeedsDisplay]; 334 | } 335 | } 336 | 337 | - (void)scrollViewDidScroll:(CGPoint)contentOffset 338 | { 339 | CGFloat yOffset = contentOffset.y; 340 | CGFloat xOffset = contentOffset.x; 341 | CGFloat overBottomOffsetY = yOffset - self.scrollView.contentSize.height + self.scrollView.frame.size.height; 342 | CGFloat centerX; 343 | CGFloat centerY; 344 | switch (self.position) { 345 | case AAPullToRefreshPositionTop: 346 | self.progress = ((yOffset + self.originalInsetTop) / -self.threshold); 347 | centerX = self.scrollView.center.x + xOffset; 348 | centerY = (yOffset + self.originalInsetTop) / 2.0f; 349 | break; 350 | case AAPullToRefreshPositionBottom: 351 | self.progress = overBottomOffsetY / self.threshold; 352 | centerX = self.scrollView.center.x + xOffset; 353 | centerY = self.scrollView.frame.size.height + self.frame.size.height / 2.0f + yOffset; 354 | if (overBottomOffsetY >= 0.0f) { 355 | centerY -= overBottomOffsetY / 1.5f; 356 | } 357 | break; 358 | case AAPullToRefreshPositionLeft: 359 | self.progress = xOffset / -self.threshold; 360 | centerX = xOffset / 2.0f; 361 | centerY = self.scrollView.bounds.size.height / 2.0f + yOffset; 362 | break; 363 | case AAPullToRefreshPositionRight: { 364 | CGFloat rightEdgeOffset = self.scrollView.contentSize.width - self.scrollView.bounds.size.width; 365 | centerX = self.scrollView.contentSize.width + MAX((xOffset - rightEdgeOffset) / 2.0f, 0); 366 | centerY = self.scrollView.bounds.size.height / 2.0f + yOffset; 367 | self.progress = MAX((xOffset - rightEdgeOffset) / self.threshold, 0); 368 | break; 369 | } 370 | default: 371 | break; 372 | } 373 | 374 | self.center = CGPointMake(centerX, centerY); 375 | switch (self.state) { 376 | case AAPullToRefreshStateNormal: //detect action 377 | if (self.isUserAction && !self.scrollView.dragging && !self.scrollView.isZooming && self.prevProgress > 0.99f) { 378 | [self actionTriggeredState]; 379 | } 380 | break; 381 | case AAPullToRefreshStateStopped: // finish 382 | case AAPullToRefreshStateLoading: // wait until stopIndicatorAnimation 383 | break; 384 | default: 385 | break; 386 | } 387 | 388 | self.isUserAction = (self.scrollView.dragging) ? YES : NO; 389 | } 390 | 391 | - (void)actionTriggeredState 392 | { 393 | self.state = AAPullToRefreshStateLoading; 394 | 395 | [UIView animateWithDuration:0.1f delay:0.0f 396 | options:UIViewAnimationOptionCurveEaseInOut|UIViewAnimationOptionAllowUserInteraction 397 | animations:^{ 398 | [self setLayerOpacity:0.0f]; 399 | } completion:^(BOOL finished) { 400 | [self setLayerHidden:YES]; 401 | }]; 402 | 403 | [self.activityIndicatorView startAnimating]; 404 | [self setupScrollViewContentInsetForLoadingIndicator:nil]; 405 | if (self.pullToRefreshHandler) 406 | self.pullToRefreshHandler(self); 407 | } 408 | 409 | - (void)actionStopState 410 | { 411 | [UIView animateWithDuration:0.2f 412 | delay:0.0f 413 | options:UIViewAnimationOptionCurveEaseInOut|UIViewAnimationOptionAllowUserInteraction 414 | animations:^{ 415 | self.activityIndicatorView.transform = CGAffineTransformMakeScale(0.1f, 0.1f); 416 | } completion:^(BOOL finished) { 417 | [self.activityIndicatorView stopAnimating]; 418 | [self resetScrollViewContentInset:^{ 419 | self.activityIndicatorView.transform = CGAffineTransformIdentity; 420 | [self setLayerHidden:NO]; 421 | [self setLayerOpacity:1.0f]; 422 | self.state = AAPullToRefreshStateNormal; 423 | }]; 424 | }]; 425 | } 426 | 427 | #pragma mark - public method 428 | - (void)stopIndicatorAnimation 429 | { 430 | [self actionStopState]; 431 | } 432 | 433 | - (void)manuallyTriggered 434 | { 435 | [self setLayerOpacity:0.0f]; 436 | 437 | UIEdgeInsets currentInsets = self.scrollView.contentInset; 438 | currentInsets.top = self.originalInsetTop + self.bounds.size.height + 20.0f; 439 | [UIView animateWithDuration:0.3f delay:0.0f options:UIViewAnimationOptionCurveEaseInOut animations:^{ 440 | self.scrollView.contentOffset = CGPointMake(self.scrollView.contentOffset.x, -currentInsets.top); 441 | } completion:^(BOOL finished) { 442 | [self actionTriggeredState]; 443 | }]; 444 | } 445 | 446 | - (void)setSize:(CGSize) size 447 | { 448 | CGRect rect = CGRectMake((self.scrollView.bounds.size.width - size.width)/2.0f, 449 | -size.height, size.width, size.height); 450 | 451 | self.frame = rect; 452 | self.shapeLayer.frame = self.bounds; 453 | self.activityIndicatorView.frame = self.bounds; 454 | self.imageLayer.frame = CGRectInset(self.bounds, self.borderWidth, self.borderWidth); 455 | 456 | self.backgroundLayer.frame = self.bounds; 457 | [self.backgroundLayer setNeedsDisplay]; 458 | } 459 | 460 | - (void)setImageIcon:(UIImage *)imageIcon 461 | { 462 | _imageIcon = imageIcon; 463 | _imageLayer.contents = (id)_imageIcon.CGImage; 464 | _imageLayer.frame = CGRectInset(self.bounds, self.borderWidth, self.borderWidth); 465 | 466 | [self setSize:_imageIcon.size]; 467 | } 468 | 469 | - (void)setBorderWidth:(CGFloat)borderWidth 470 | { 471 | _borderWidth = borderWidth; 472 | 473 | _backgroundLayer.outlineWidth = _borderWidth; 474 | [_backgroundLayer setNeedsDisplay]; 475 | 476 | _shapeLayer.lineWidth = _borderWidth; 477 | _imageLayer.frame = CGRectInset(self.bounds, self.borderWidth, self.borderWidth); 478 | } 479 | 480 | - (void)setBorderColor:(UIColor *)borderColor 481 | { 482 | _borderColor = borderColor; 483 | _shapeLayer.strokeColor = _borderColor.CGColor; 484 | } 485 | 486 | - (void)setActivityIndicatorView:(UIActivityIndicatorView *)activityIndicatorView 487 | { 488 | if(_activityIndicatorView) 489 | [activityIndicatorView removeFromSuperview]; 490 | _activityIndicatorView = activityIndicatorView; 491 | _activityIndicatorView.hidesWhenStopped = YES; 492 | _activityIndicatorView.frame = self.bounds; 493 | [self addSubview:_activityIndicatorView]; 494 | 495 | } 496 | 497 | @end 498 | -------------------------------------------------------------------------------- /AAPullToRefresh/centerIcon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/r-plus/AAPullToRefresh/9d756b85c0e9993be5a34703b0af802e8ab7eec5/AAPullToRefresh/centerIcon@2x.png -------------------------------------------------------------------------------- /AAPullToRefresh/launchpad@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/r-plus/AAPullToRefresh/9d756b85c0e9993be5a34703b0af802e8ab7eec5/AAPullToRefresh/launchpad@2x.png -------------------------------------------------------------------------------- /AAPullToRefreshDemo/AAPullToRefreshDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 0A1458AE1854ABB40042FF82 /* AAPullToRefresh.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A1458AA1854ABB40042FF82 /* AAPullToRefresh.m */; }; 11 | 0A1458AF1854ABB40042FF82 /* centerIcon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 0A1458AB1854ABB40042FF82 /* centerIcon@2x.png */; }; 12 | 0A1458B81854B9390042FF82 /* launchpad@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 0A1458B71854B9390042FF82 /* launchpad@2x.png */; }; 13 | 0A80CD0E1854A58500A8852E /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A80CD0D1854A58500A8852E /* Foundation.framework */; }; 14 | 0A80CD101854A58500A8852E /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A80CD0F1854A58500A8852E /* CoreGraphics.framework */; }; 15 | 0A80CD121854A58500A8852E /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A80CD111854A58500A8852E /* UIKit.framework */; }; 16 | 0A80CD181854A58600A8852E /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 0A80CD161854A58600A8852E /* InfoPlist.strings */; }; 17 | 0A80CD1A1854A58600A8852E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A80CD191854A58600A8852E /* main.m */; }; 18 | 0A80CD1E1854A58600A8852E /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A80CD1D1854A58600A8852E /* AppDelegate.m */; }; 19 | 0A80CD211854A58600A8852E /* Main_iPhone.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0A80CD1F1854A58600A8852E /* Main_iPhone.storyboard */; }; 20 | 0A80CD271854A58600A8852E /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A80CD261854A58600A8852E /* ViewController.m */; }; 21 | 0A80CD291854A58600A8852E /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0A80CD281854A58600A8852E /* Images.xcassets */; }; 22 | 0A80CD301854A58600A8852E /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A80CD2F1854A58600A8852E /* XCTest.framework */; }; 23 | 0A80CD311854A58600A8852E /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A80CD0D1854A58500A8852E /* Foundation.framework */; }; 24 | 0A80CD321854A58600A8852E /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A80CD111854A58500A8852E /* UIKit.framework */; }; 25 | 0A80CD3A1854A58600A8852E /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 0A80CD381854A58600A8852E /* InfoPlist.strings */; }; 26 | 0A80CD3C1854A58600A8852E /* AAPullToRefreshDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A80CD3B1854A58600A8852E /* AAPullToRefreshDemoTests.m */; }; 27 | 0AC83EB219E1131C008C7752 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 0AC83EB119E1131C008C7752 /* LaunchScreen.xib */; }; 28 | /* End PBXBuildFile section */ 29 | 30 | /* Begin PBXContainerItemProxy section */ 31 | 0A80CD331854A58600A8852E /* PBXContainerItemProxy */ = { 32 | isa = PBXContainerItemProxy; 33 | containerPortal = 0A80CD021854A58500A8852E /* Project object */; 34 | proxyType = 1; 35 | remoteGlobalIDString = 0A80CD091854A58500A8852E; 36 | remoteInfo = AAPullToRefreshDemo; 37 | }; 38 | /* End PBXContainerItemProxy section */ 39 | 40 | /* Begin PBXFileReference section */ 41 | 0A1458A91854ABB40042FF82 /* AAPullToRefresh.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AAPullToRefresh.h; sourceTree = ""; }; 42 | 0A1458AA1854ABB40042FF82 /* AAPullToRefresh.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AAPullToRefresh.m; sourceTree = ""; }; 43 | 0A1458AB1854ABB40042FF82 /* centerIcon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "centerIcon@2x.png"; sourceTree = ""; }; 44 | 0A1458B71854B9390042FF82 /* launchpad@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "launchpad@2x.png"; sourceTree = ""; }; 45 | 0A80CD0A1854A58500A8852E /* AAPullToRefreshDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AAPullToRefreshDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 46 | 0A80CD0D1854A58500A8852E /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 47 | 0A80CD0F1854A58500A8852E /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 48 | 0A80CD111854A58500A8852E /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 49 | 0A80CD151854A58600A8852E /* AAPullToRefreshDemo-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "AAPullToRefreshDemo-Info.plist"; sourceTree = ""; }; 50 | 0A80CD171854A58600A8852E /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 51 | 0A80CD191854A58600A8852E /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 52 | 0A80CD1B1854A58600A8852E /* AAPullToRefreshDemo-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "AAPullToRefreshDemo-Prefix.pch"; sourceTree = ""; }; 53 | 0A80CD1C1854A58600A8852E /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 54 | 0A80CD1D1854A58600A8852E /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 55 | 0A80CD201854A58600A8852E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main_iPhone.storyboard; sourceTree = ""; }; 56 | 0A80CD251854A58600A8852E /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 57 | 0A80CD261854A58600A8852E /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 58 | 0A80CD281854A58600A8852E /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 59 | 0A80CD2E1854A58600A8852E /* AAPullToRefreshDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AAPullToRefreshDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 60 | 0A80CD2F1854A58600A8852E /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 61 | 0A80CD371854A58600A8852E /* AAPullToRefreshDemoTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "AAPullToRefreshDemoTests-Info.plist"; sourceTree = ""; }; 62 | 0A80CD391854A58600A8852E /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 63 | 0A80CD3B1854A58600A8852E /* AAPullToRefreshDemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AAPullToRefreshDemoTests.m; sourceTree = ""; }; 64 | 0AC83EB119E1131C008C7752 /* LaunchScreen.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = LaunchScreen.xib; sourceTree = ""; }; 65 | /* End PBXFileReference section */ 66 | 67 | /* Begin PBXFrameworksBuildPhase section */ 68 | 0A80CD071854A58500A8852E /* Frameworks */ = { 69 | isa = PBXFrameworksBuildPhase; 70 | buildActionMask = 2147483647; 71 | files = ( 72 | 0A80CD101854A58500A8852E /* CoreGraphics.framework in Frameworks */, 73 | 0A80CD121854A58500A8852E /* UIKit.framework in Frameworks */, 74 | 0A80CD0E1854A58500A8852E /* Foundation.framework in Frameworks */, 75 | ); 76 | runOnlyForDeploymentPostprocessing = 0; 77 | }; 78 | 0A80CD2B1854A58600A8852E /* Frameworks */ = { 79 | isa = PBXFrameworksBuildPhase; 80 | buildActionMask = 2147483647; 81 | files = ( 82 | 0A80CD301854A58600A8852E /* XCTest.framework in Frameworks */, 83 | 0A80CD321854A58600A8852E /* UIKit.framework in Frameworks */, 84 | 0A80CD311854A58600A8852E /* Foundation.framework in Frameworks */, 85 | ); 86 | runOnlyForDeploymentPostprocessing = 0; 87 | }; 88 | /* End PBXFrameworksBuildPhase section */ 89 | 90 | /* Begin PBXGroup section */ 91 | 0A1458A81854ABB40042FF82 /* AAPullToRefresh */ = { 92 | isa = PBXGroup; 93 | children = ( 94 | 0A1458AB1854ABB40042FF82 /* centerIcon@2x.png */, 95 | 0A1458B71854B9390042FF82 /* launchpad@2x.png */, 96 | 0A1458A91854ABB40042FF82 /* AAPullToRefresh.h */, 97 | 0A1458AA1854ABB40042FF82 /* AAPullToRefresh.m */, 98 | ); 99 | name = AAPullToRefresh; 100 | path = ../AAPullToRefresh; 101 | sourceTree = ""; 102 | }; 103 | 0A80CD011854A58500A8852E = { 104 | isa = PBXGroup; 105 | children = ( 106 | 0A1458A81854ABB40042FF82 /* AAPullToRefresh */, 107 | 0A80CD131854A58500A8852E /* AAPullToRefreshDemo */, 108 | 0A80CD351854A58600A8852E /* AAPullToRefreshDemoTests */, 109 | 0A80CD0C1854A58500A8852E /* Frameworks */, 110 | 0A80CD0B1854A58500A8852E /* Products */, 111 | ); 112 | sourceTree = ""; 113 | }; 114 | 0A80CD0B1854A58500A8852E /* Products */ = { 115 | isa = PBXGroup; 116 | children = ( 117 | 0A80CD0A1854A58500A8852E /* AAPullToRefreshDemo.app */, 118 | 0A80CD2E1854A58600A8852E /* AAPullToRefreshDemoTests.xctest */, 119 | ); 120 | name = Products; 121 | sourceTree = ""; 122 | }; 123 | 0A80CD0C1854A58500A8852E /* Frameworks */ = { 124 | isa = PBXGroup; 125 | children = ( 126 | 0A80CD0D1854A58500A8852E /* Foundation.framework */, 127 | 0A80CD0F1854A58500A8852E /* CoreGraphics.framework */, 128 | 0A80CD111854A58500A8852E /* UIKit.framework */, 129 | 0A80CD2F1854A58600A8852E /* XCTest.framework */, 130 | ); 131 | name = Frameworks; 132 | sourceTree = ""; 133 | }; 134 | 0A80CD131854A58500A8852E /* AAPullToRefreshDemo */ = { 135 | isa = PBXGroup; 136 | children = ( 137 | 0A80CD1C1854A58600A8852E /* AppDelegate.h */, 138 | 0A80CD1D1854A58600A8852E /* AppDelegate.m */, 139 | 0A80CD1F1854A58600A8852E /* Main_iPhone.storyboard */, 140 | 0A80CD251854A58600A8852E /* ViewController.h */, 141 | 0AC83EB119E1131C008C7752 /* LaunchScreen.xib */, 142 | 0A80CD261854A58600A8852E /* ViewController.m */, 143 | 0A80CD281854A58600A8852E /* Images.xcassets */, 144 | 0A80CD141854A58600A8852E /* Supporting Files */, 145 | ); 146 | path = AAPullToRefreshDemo; 147 | sourceTree = ""; 148 | }; 149 | 0A80CD141854A58600A8852E /* Supporting Files */ = { 150 | isa = PBXGroup; 151 | children = ( 152 | 0A80CD151854A58600A8852E /* AAPullToRefreshDemo-Info.plist */, 153 | 0A80CD161854A58600A8852E /* InfoPlist.strings */, 154 | 0A80CD191854A58600A8852E /* main.m */, 155 | 0A80CD1B1854A58600A8852E /* AAPullToRefreshDemo-Prefix.pch */, 156 | ); 157 | name = "Supporting Files"; 158 | sourceTree = ""; 159 | }; 160 | 0A80CD351854A58600A8852E /* AAPullToRefreshDemoTests */ = { 161 | isa = PBXGroup; 162 | children = ( 163 | 0A80CD3B1854A58600A8852E /* AAPullToRefreshDemoTests.m */, 164 | 0A80CD361854A58600A8852E /* Supporting Files */, 165 | ); 166 | path = AAPullToRefreshDemoTests; 167 | sourceTree = ""; 168 | }; 169 | 0A80CD361854A58600A8852E /* Supporting Files */ = { 170 | isa = PBXGroup; 171 | children = ( 172 | 0A80CD371854A58600A8852E /* AAPullToRefreshDemoTests-Info.plist */, 173 | 0A80CD381854A58600A8852E /* InfoPlist.strings */, 174 | ); 175 | name = "Supporting Files"; 176 | sourceTree = ""; 177 | }; 178 | /* End PBXGroup section */ 179 | 180 | /* Begin PBXNativeTarget section */ 181 | 0A80CD091854A58500A8852E /* AAPullToRefreshDemo */ = { 182 | isa = PBXNativeTarget; 183 | buildConfigurationList = 0A80CD3F1854A58600A8852E /* Build configuration list for PBXNativeTarget "AAPullToRefreshDemo" */; 184 | buildPhases = ( 185 | 0A80CD061854A58500A8852E /* Sources */, 186 | 0A80CD071854A58500A8852E /* Frameworks */, 187 | 0A80CD081854A58500A8852E /* Resources */, 188 | ); 189 | buildRules = ( 190 | ); 191 | dependencies = ( 192 | ); 193 | name = AAPullToRefreshDemo; 194 | productName = AAPullToRefreshDemo; 195 | productReference = 0A80CD0A1854A58500A8852E /* AAPullToRefreshDemo.app */; 196 | productType = "com.apple.product-type.application"; 197 | }; 198 | 0A80CD2D1854A58600A8852E /* AAPullToRefreshDemoTests */ = { 199 | isa = PBXNativeTarget; 200 | buildConfigurationList = 0A80CD421854A58600A8852E /* Build configuration list for PBXNativeTarget "AAPullToRefreshDemoTests" */; 201 | buildPhases = ( 202 | 0A80CD2A1854A58600A8852E /* Sources */, 203 | 0A80CD2B1854A58600A8852E /* Frameworks */, 204 | 0A80CD2C1854A58600A8852E /* Resources */, 205 | ); 206 | buildRules = ( 207 | ); 208 | dependencies = ( 209 | 0A80CD341854A58600A8852E /* PBXTargetDependency */, 210 | ); 211 | name = AAPullToRefreshDemoTests; 212 | productName = AAPullToRefreshDemoTests; 213 | productReference = 0A80CD2E1854A58600A8852E /* AAPullToRefreshDemoTests.xctest */; 214 | productType = "com.apple.product-type.bundle.unit-test"; 215 | }; 216 | /* End PBXNativeTarget section */ 217 | 218 | /* Begin PBXProject section */ 219 | 0A80CD021854A58500A8852E /* Project object */ = { 220 | isa = PBXProject; 221 | attributes = { 222 | LastUpgradeCheck = 0500; 223 | ORGANIZATIONNAME = "r-plus"; 224 | TargetAttributes = { 225 | 0A80CD2D1854A58600A8852E = { 226 | TestTargetID = 0A80CD091854A58500A8852E; 227 | }; 228 | }; 229 | }; 230 | buildConfigurationList = 0A80CD051854A58500A8852E /* Build configuration list for PBXProject "AAPullToRefreshDemo" */; 231 | compatibilityVersion = "Xcode 3.2"; 232 | developmentRegion = English; 233 | hasScannedForEncodings = 0; 234 | knownRegions = ( 235 | en, 236 | Base, 237 | ); 238 | mainGroup = 0A80CD011854A58500A8852E; 239 | productRefGroup = 0A80CD0B1854A58500A8852E /* Products */; 240 | projectDirPath = ""; 241 | projectRoot = ""; 242 | targets = ( 243 | 0A80CD091854A58500A8852E /* AAPullToRefreshDemo */, 244 | 0A80CD2D1854A58600A8852E /* AAPullToRefreshDemoTests */, 245 | ); 246 | }; 247 | /* End PBXProject section */ 248 | 249 | /* Begin PBXResourcesBuildPhase section */ 250 | 0A80CD081854A58500A8852E /* Resources */ = { 251 | isa = PBXResourcesBuildPhase; 252 | buildActionMask = 2147483647; 253 | files = ( 254 | 0A1458B81854B9390042FF82 /* launchpad@2x.png in Resources */, 255 | 0A80CD291854A58600A8852E /* Images.xcassets in Resources */, 256 | 0A80CD211854A58600A8852E /* Main_iPhone.storyboard in Resources */, 257 | 0A80CD181854A58600A8852E /* InfoPlist.strings in Resources */, 258 | 0AC83EB219E1131C008C7752 /* LaunchScreen.xib in Resources */, 259 | 0A1458AF1854ABB40042FF82 /* centerIcon@2x.png in Resources */, 260 | ); 261 | runOnlyForDeploymentPostprocessing = 0; 262 | }; 263 | 0A80CD2C1854A58600A8852E /* Resources */ = { 264 | isa = PBXResourcesBuildPhase; 265 | buildActionMask = 2147483647; 266 | files = ( 267 | 0A80CD3A1854A58600A8852E /* InfoPlist.strings in Resources */, 268 | ); 269 | runOnlyForDeploymentPostprocessing = 0; 270 | }; 271 | /* End PBXResourcesBuildPhase section */ 272 | 273 | /* Begin PBXSourcesBuildPhase section */ 274 | 0A80CD061854A58500A8852E /* Sources */ = { 275 | isa = PBXSourcesBuildPhase; 276 | buildActionMask = 2147483647; 277 | files = ( 278 | 0A80CD271854A58600A8852E /* ViewController.m in Sources */, 279 | 0A1458AE1854ABB40042FF82 /* AAPullToRefresh.m in Sources */, 280 | 0A80CD1E1854A58600A8852E /* AppDelegate.m in Sources */, 281 | 0A80CD1A1854A58600A8852E /* main.m in Sources */, 282 | ); 283 | runOnlyForDeploymentPostprocessing = 0; 284 | }; 285 | 0A80CD2A1854A58600A8852E /* Sources */ = { 286 | isa = PBXSourcesBuildPhase; 287 | buildActionMask = 2147483647; 288 | files = ( 289 | 0A80CD3C1854A58600A8852E /* AAPullToRefreshDemoTests.m in Sources */, 290 | ); 291 | runOnlyForDeploymentPostprocessing = 0; 292 | }; 293 | /* End PBXSourcesBuildPhase section */ 294 | 295 | /* Begin PBXTargetDependency section */ 296 | 0A80CD341854A58600A8852E /* PBXTargetDependency */ = { 297 | isa = PBXTargetDependency; 298 | target = 0A80CD091854A58500A8852E /* AAPullToRefreshDemo */; 299 | targetProxy = 0A80CD331854A58600A8852E /* PBXContainerItemProxy */; 300 | }; 301 | /* End PBXTargetDependency section */ 302 | 303 | /* Begin PBXVariantGroup section */ 304 | 0A80CD161854A58600A8852E /* InfoPlist.strings */ = { 305 | isa = PBXVariantGroup; 306 | children = ( 307 | 0A80CD171854A58600A8852E /* en */, 308 | ); 309 | name = InfoPlist.strings; 310 | sourceTree = ""; 311 | }; 312 | 0A80CD1F1854A58600A8852E /* Main_iPhone.storyboard */ = { 313 | isa = PBXVariantGroup; 314 | children = ( 315 | 0A80CD201854A58600A8852E /* Base */, 316 | ); 317 | name = Main_iPhone.storyboard; 318 | sourceTree = ""; 319 | }; 320 | 0A80CD381854A58600A8852E /* InfoPlist.strings */ = { 321 | isa = PBXVariantGroup; 322 | children = ( 323 | 0A80CD391854A58600A8852E /* en */, 324 | ); 325 | name = InfoPlist.strings; 326 | sourceTree = ""; 327 | }; 328 | /* End PBXVariantGroup section */ 329 | 330 | /* Begin XCBuildConfiguration section */ 331 | 0A80CD3D1854A58600A8852E /* Debug */ = { 332 | isa = XCBuildConfiguration; 333 | buildSettings = { 334 | ALWAYS_SEARCH_USER_PATHS = NO; 335 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 336 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 337 | CLANG_CXX_LIBRARY = "libc++"; 338 | CLANG_ENABLE_MODULES = YES; 339 | CLANG_ENABLE_OBJC_ARC = YES; 340 | CLANG_WARN_BOOL_CONVERSION = YES; 341 | CLANG_WARN_CONSTANT_CONVERSION = YES; 342 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 343 | CLANG_WARN_EMPTY_BODY = YES; 344 | CLANG_WARN_ENUM_CONVERSION = YES; 345 | CLANG_WARN_INT_CONVERSION = YES; 346 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 347 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 348 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 349 | COPY_PHASE_STRIP = NO; 350 | GCC_C_LANGUAGE_STANDARD = gnu99; 351 | GCC_DYNAMIC_NO_PIC = NO; 352 | GCC_OPTIMIZATION_LEVEL = 0; 353 | GCC_PREPROCESSOR_DEFINITIONS = ( 354 | "DEBUG=1", 355 | "$(inherited)", 356 | ); 357 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 358 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 359 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 360 | GCC_WARN_UNDECLARED_SELECTOR = YES; 361 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 362 | GCC_WARN_UNUSED_FUNCTION = YES; 363 | GCC_WARN_UNUSED_VARIABLE = YES; 364 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 365 | ONLY_ACTIVE_ARCH = YES; 366 | SDKROOT = iphoneos; 367 | TARGETED_DEVICE_FAMILY = "1,2"; 368 | }; 369 | name = Debug; 370 | }; 371 | 0A80CD3E1854A58600A8852E /* Release */ = { 372 | isa = XCBuildConfiguration; 373 | buildSettings = { 374 | ALWAYS_SEARCH_USER_PATHS = NO; 375 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 376 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 377 | CLANG_CXX_LIBRARY = "libc++"; 378 | CLANG_ENABLE_MODULES = YES; 379 | CLANG_ENABLE_OBJC_ARC = YES; 380 | CLANG_WARN_BOOL_CONVERSION = YES; 381 | CLANG_WARN_CONSTANT_CONVERSION = YES; 382 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 383 | CLANG_WARN_EMPTY_BODY = YES; 384 | CLANG_WARN_ENUM_CONVERSION = YES; 385 | CLANG_WARN_INT_CONVERSION = YES; 386 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 387 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 388 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 389 | COPY_PHASE_STRIP = YES; 390 | ENABLE_NS_ASSERTIONS = NO; 391 | GCC_C_LANGUAGE_STANDARD = gnu99; 392 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 393 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 394 | GCC_WARN_UNDECLARED_SELECTOR = YES; 395 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 396 | GCC_WARN_UNUSED_FUNCTION = YES; 397 | GCC_WARN_UNUSED_VARIABLE = YES; 398 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 399 | SDKROOT = iphoneos; 400 | TARGETED_DEVICE_FAMILY = "1,2"; 401 | VALIDATE_PRODUCT = YES; 402 | }; 403 | name = Release; 404 | }; 405 | 0A80CD401854A58600A8852E /* Debug */ = { 406 | isa = XCBuildConfiguration; 407 | buildSettings = { 408 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 409 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 410 | GCC_PREFIX_HEADER = "AAPullToRefreshDemo/AAPullToRefreshDemo-Prefix.pch"; 411 | INFOPLIST_FILE = "AAPullToRefreshDemo/AAPullToRefreshDemo-Info.plist"; 412 | IPHONEOS_DEPLOYMENT_TARGET = 6.0; 413 | PRODUCT_NAME = "$(TARGET_NAME)"; 414 | TARGETED_DEVICE_FAMILY = 1; 415 | WRAPPER_EXTENSION = app; 416 | }; 417 | name = Debug; 418 | }; 419 | 0A80CD411854A58600A8852E /* Release */ = { 420 | isa = XCBuildConfiguration; 421 | buildSettings = { 422 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 423 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 424 | GCC_PREFIX_HEADER = "AAPullToRefreshDemo/AAPullToRefreshDemo-Prefix.pch"; 425 | INFOPLIST_FILE = "AAPullToRefreshDemo/AAPullToRefreshDemo-Info.plist"; 426 | IPHONEOS_DEPLOYMENT_TARGET = 6.0; 427 | PRODUCT_NAME = "$(TARGET_NAME)"; 428 | TARGETED_DEVICE_FAMILY = 1; 429 | WRAPPER_EXTENSION = app; 430 | }; 431 | name = Release; 432 | }; 433 | 0A80CD431854A58600A8852E /* Debug */ = { 434 | isa = XCBuildConfiguration; 435 | buildSettings = { 436 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 437 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/AAPullToRefreshDemo.app/AAPullToRefreshDemo"; 438 | FRAMEWORK_SEARCH_PATHS = ( 439 | "$(SDKROOT)/Developer/Library/Frameworks", 440 | "$(inherited)", 441 | "$(DEVELOPER_FRAMEWORKS_DIR)", 442 | ); 443 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 444 | GCC_PREFIX_HEADER = "AAPullToRefreshDemo/AAPullToRefreshDemo-Prefix.pch"; 445 | GCC_PREPROCESSOR_DEFINITIONS = ( 446 | "DEBUG=1", 447 | "$(inherited)", 448 | ); 449 | INFOPLIST_FILE = "AAPullToRefreshDemoTests/AAPullToRefreshDemoTests-Info.plist"; 450 | PRODUCT_NAME = "$(TARGET_NAME)"; 451 | TEST_HOST = "$(BUNDLE_LOADER)"; 452 | WRAPPER_EXTENSION = xctest; 453 | }; 454 | name = Debug; 455 | }; 456 | 0A80CD441854A58600A8852E /* Release */ = { 457 | isa = XCBuildConfiguration; 458 | buildSettings = { 459 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 460 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/AAPullToRefreshDemo.app/AAPullToRefreshDemo"; 461 | FRAMEWORK_SEARCH_PATHS = ( 462 | "$(SDKROOT)/Developer/Library/Frameworks", 463 | "$(inherited)", 464 | "$(DEVELOPER_FRAMEWORKS_DIR)", 465 | ); 466 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 467 | GCC_PREFIX_HEADER = "AAPullToRefreshDemo/AAPullToRefreshDemo-Prefix.pch"; 468 | INFOPLIST_FILE = "AAPullToRefreshDemoTests/AAPullToRefreshDemoTests-Info.plist"; 469 | PRODUCT_NAME = "$(TARGET_NAME)"; 470 | TEST_HOST = "$(BUNDLE_LOADER)"; 471 | WRAPPER_EXTENSION = xctest; 472 | }; 473 | name = Release; 474 | }; 475 | /* End XCBuildConfiguration section */ 476 | 477 | /* Begin XCConfigurationList section */ 478 | 0A80CD051854A58500A8852E /* Build configuration list for PBXProject "AAPullToRefreshDemo" */ = { 479 | isa = XCConfigurationList; 480 | buildConfigurations = ( 481 | 0A80CD3D1854A58600A8852E /* Debug */, 482 | 0A80CD3E1854A58600A8852E /* Release */, 483 | ); 484 | defaultConfigurationIsVisible = 0; 485 | defaultConfigurationName = Release; 486 | }; 487 | 0A80CD3F1854A58600A8852E /* Build configuration list for PBXNativeTarget "AAPullToRefreshDemo" */ = { 488 | isa = XCConfigurationList; 489 | buildConfigurations = ( 490 | 0A80CD401854A58600A8852E /* Debug */, 491 | 0A80CD411854A58600A8852E /* Release */, 492 | ); 493 | defaultConfigurationIsVisible = 0; 494 | defaultConfigurationName = Release; 495 | }; 496 | 0A80CD421854A58600A8852E /* Build configuration list for PBXNativeTarget "AAPullToRefreshDemoTests" */ = { 497 | isa = XCConfigurationList; 498 | buildConfigurations = ( 499 | 0A80CD431854A58600A8852E /* Debug */, 500 | 0A80CD441854A58600A8852E /* Release */, 501 | ); 502 | defaultConfigurationIsVisible = 0; 503 | defaultConfigurationName = Release; 504 | }; 505 | /* End XCConfigurationList section */ 506 | }; 507 | rootObject = 0A80CD021854A58500A8852E /* Project object */; 508 | } 509 | -------------------------------------------------------------------------------- /AAPullToRefreshDemo/AAPullToRefreshDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /AAPullToRefreshDemo/AAPullToRefreshDemo/AAPullToRefreshDemo-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | jp.r-plus.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main_iPhone 31 | UIMainStoryboardFile~ipad 32 | Main_iPad 33 | UIRequiredDeviceCapabilities 34 | 35 | armv7 36 | 37 | UISupportedInterfaceOrientations 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationLandscapeLeft 41 | UIInterfaceOrientationLandscapeRight 42 | 43 | UISupportedInterfaceOrientations~ipad 44 | 45 | UIInterfaceOrientationPortrait 46 | UIInterfaceOrientationPortraitUpsideDown 47 | UIInterfaceOrientationLandscapeLeft 48 | UIInterfaceOrientationLandscapeRight 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /AAPullToRefreshDemo/AAPullToRefreshDemo/AAPullToRefreshDemo-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #import 8 | 9 | #ifndef __IPHONE_5_0 10 | #warning "This project uses features only available in iOS SDK 5.0 and later." 11 | #endif 12 | 13 | #ifdef __OBJC__ 14 | #import 15 | #import 16 | #endif 17 | -------------------------------------------------------------------------------- /AAPullToRefreshDemo/AAPullToRefreshDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // AAPullToRefreshDemo 4 | // 5 | // Created by hyde on 2013/12/08. 6 | // Copyright (c) 2013年 r-plus. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /AAPullToRefreshDemo/AAPullToRefreshDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // AAPullToRefreshDemo 4 | // 5 | // Created by hyde on 2013/12/08. 6 | // Copyright (c) 2013年 r-plus. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @implementation AppDelegate 12 | 13 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 14 | { 15 | // Override point for customization after application launch. 16 | return YES; 17 | } 18 | 19 | - (void)applicationWillResignActive:(UIApplication *)application 20 | { 21 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 22 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 23 | } 24 | 25 | - (void)applicationDidEnterBackground:(UIApplication *)application 26 | { 27 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 28 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 29 | } 30 | 31 | - (void)applicationWillEnterForeground:(UIApplication *)application 32 | { 33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | - (void)applicationDidBecomeActive:(UIApplication *)application 37 | { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application 42 | { 43 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /AAPullToRefreshDemo/AAPullToRefreshDemo/Base.lproj/Main_iPad.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /AAPullToRefreshDemo/AAPullToRefreshDemo/Base.lproj/Main_iPhone.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /AAPullToRefreshDemo/AAPullToRefreshDemo/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "40x40", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "60x60", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "60x60", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "ipad", 25 | "size" : "29x29", 26 | "scale" : "1x" 27 | }, 28 | { 29 | "idiom" : "ipad", 30 | "size" : "29x29", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "40x40", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "40x40", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "76x76", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "76x76", 51 | "scale" : "2x" 52 | } 53 | ], 54 | "info" : { 55 | "version" : 1, 56 | "author" : "xcode" 57 | } 58 | } -------------------------------------------------------------------------------- /AAPullToRefreshDemo/AAPullToRefreshDemo/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "7.0", 8 | "scale" : "2x" 9 | }, 10 | { 11 | "orientation" : "portrait", 12 | "idiom" : "iphone", 13 | "subtype" : "retina4", 14 | "extent" : "full-screen", 15 | "minimum-system-version" : "7.0", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "orientation" : "portrait", 20 | "idiom" : "ipad", 21 | "extent" : "full-screen", 22 | "minimum-system-version" : "7.0", 23 | "scale" : "1x" 24 | }, 25 | { 26 | "orientation" : "landscape", 27 | "idiom" : "ipad", 28 | "extent" : "full-screen", 29 | "minimum-system-version" : "7.0", 30 | "scale" : "1x" 31 | }, 32 | { 33 | "orientation" : "portrait", 34 | "idiom" : "ipad", 35 | "extent" : "full-screen", 36 | "minimum-system-version" : "7.0", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "orientation" : "landscape", 41 | "idiom" : "ipad", 42 | "extent" : "full-screen", 43 | "minimum-system-version" : "7.0", 44 | "scale" : "2x" 45 | } 46 | ], 47 | "info" : { 48 | "version" : 1, 49 | "author" : "xcode" 50 | } 51 | } -------------------------------------------------------------------------------- /AAPullToRefreshDemo/AAPullToRefreshDemo/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /AAPullToRefreshDemo/AAPullToRefreshDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // AAPullToRefreshDemo 4 | // 5 | // Created by hyde on 2013/12/08. 6 | // Copyright (c) 2013年 r-plus. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /AAPullToRefreshDemo/AAPullToRefreshDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // AAPullToRefreshDemo 4 | // 5 | // Created by hyde on 2013/12/08. 6 | // Copyright (c) 2013年 r-plus. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "AAPullToRefresh.h" 11 | 12 | @interface ViewController () 13 | @property (nonatomic, strong) UIView *thresholdView; 14 | @property (nonatomic, strong) UIScrollView *scrollView; 15 | @end 16 | 17 | @implementation ViewController 18 | 19 | - (void)viewDidLoad 20 | { 21 | [super viewDidLoad]; 22 | self.scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds]; 23 | self.scrollView.delegate = self; 24 | self.scrollView.maximumZoomScale = 2.0f; 25 | self.scrollView.contentSize = self.view.bounds.size; 26 | self.scrollView.alwaysBounceHorizontal = YES; 27 | self.scrollView.alwaysBounceVertical = YES; 28 | self.scrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 29 | self.scrollView.backgroundColor = UIColor.lightGrayColor; 30 | [self.view addSubview:self.scrollView]; 31 | 32 | CGRect rect = self.scrollView.bounds; 33 | rect.size.height = self.scrollView.contentSize.height; 34 | self.thresholdView = [[UIView alloc] initWithFrame:rect]; 35 | self.thresholdView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 36 | self.thresholdView.userInteractionEnabled = NO; 37 | self.thresholdView.backgroundColor = UIColor.whiteColor; 38 | [self.scrollView addSubview:self.thresholdView]; 39 | 40 | // top 41 | AAPullToRefresh *tv = [self.scrollView addPullToRefreshPosition:AAPullToRefreshPositionTop actionHandler:^(AAPullToRefresh *v){ 42 | NSLog(@"fire from top"); 43 | [v performSelector:@selector(stopIndicatorAnimation) withObject:nil afterDelay:1.0f]; 44 | }]; 45 | tv.imageIcon = [UIImage imageNamed:@"launchpad"]; 46 | tv.borderColor = [UIColor whiteColor]; 47 | 48 | // bottom 49 | AAPullToRefresh *bv = [self.scrollView addPullToRefreshPosition:AAPullToRefreshPositionBottom actionHandler:^(AAPullToRefresh *v){ 50 | NSLog(@"fire from bottom"); 51 | [v performSelector:@selector(stopIndicatorAnimation) withObject:nil afterDelay:1.0f]; 52 | }]; 53 | bv.imageIcon = [UIImage imageNamed:@"launchpad"]; 54 | bv.borderColor = [UIColor whiteColor]; 55 | 56 | // left 57 | [self.scrollView addPullToRefreshPosition:AAPullToRefreshPositionLeft actionHandler:^(AAPullToRefresh *v){ 58 | NSLog(@"fire from left"); 59 | [v performSelector:@selector(stopIndicatorAnimation) withObject:nil afterDelay:1.0f]; 60 | }]; 61 | 62 | // right 63 | [self.scrollView addPullToRefreshPosition:AAPullToRefreshPositionRight actionHandler:^(AAPullToRefresh *v){ 64 | NSLog(@"fire from right"); 65 | [v performSelector:@selector(stopIndicatorAnimation) withObject:nil afterDelay:1.0f]; 66 | }]; 67 | } 68 | 69 | - (void)didReceiveMemoryWarning 70 | { 71 | [super didReceiveMemoryWarning]; 72 | // Dispose of any resources that can be recreated. 73 | } 74 | 75 | - (void)viewWillLayoutSubviews 76 | { 77 | CGRect rect = self.scrollView.bounds; 78 | rect.size.height = self.scrollView.contentSize.height; 79 | self.thresholdView.frame = rect; 80 | } 81 | 82 | - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView 83 | { 84 | return self.thresholdView; 85 | } 86 | 87 | @end 88 | -------------------------------------------------------------------------------- /AAPullToRefreshDemo/AAPullToRefreshDemo/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /AAPullToRefreshDemo/AAPullToRefreshDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // AAPullToRefreshDemo 4 | // 5 | // Created by hyde on 2013/12/08. 6 | // Copyright (c) 2013年 r-plus. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "AppDelegate.h" 12 | 13 | int main(int argc, char * argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /AAPullToRefreshDemo/AAPullToRefreshDemoTests/AAPullToRefreshDemoTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | jp.r-plus.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /AAPullToRefreshDemo/AAPullToRefreshDemoTests/AAPullToRefreshDemoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // AAPullToRefreshDemoTests.m 3 | // AAPullToRefreshDemoTests 4 | // 5 | // Created by hyde on 2013/12/08. 6 | // Copyright (c) 2013年 r-plus. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AAPullToRefreshDemoTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation AAPullToRefreshDemoTests 16 | 17 | - (void)setUp 18 | { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown 24 | { 25 | // Put teardown code here. This method is called after the invocation of each test method in the class. 26 | [super tearDown]; 27 | } 28 | 29 | - (void)testExample 30 | { 31 | XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__); 32 | } 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /AAPullToRefreshDemo/AAPullToRefreshDemoTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | AAPullToRefresh 2 | 3 | The MIT License (MIT) 4 | 5 | Copyright (c) 2013 r-plus 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | this software and associated documentation files (the "Software"), to deal in 9 | the Software without restriction, including without limitation the rights to 10 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | the Software, and to permit persons to whom the Software is furnished to do so, 12 | subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | ///////////////////////////////////////////////////////////////////////////// 25 | 26 | UzysCircularProgressPullToRefresh 27 | https://github.com/uzysjung/UzysCircularProgressPullToRefresh 28 | 29 | The MIT License (MIT) 30 | 31 | Copyright (c) 2013 Jaehoon Jung 32 | 33 | Permission is hereby granted, free of charge, to any person obtaining a copy of 34 | this software and associated documentation files (the "Software"), to deal in 35 | the Software without restriction, including without limitation the rights to 36 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 37 | the Software, and to permit persons to whom the Software is furnished to do so, 38 | subject to the following conditions: 39 | 40 | The above copyright notice and this permission notice shall be included in all 41 | copies or substantial portions of the Software. 42 | 43 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 44 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 45 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 46 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 47 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 48 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 49 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | AAPullToRefresh 2 | =============== 3 | 4 | All around pull to refresh library. 5 | 6 | ![DemoGif](http://f.cl.ly/items/1H1r3g3g20241k3f0Y3z/demo3.gif) 7 | 8 | ## Requirement 9 | - ARC. 10 | - iOS 6 or higher(tested on iOS 6, 7 and 8). 11 | 12 | ## Install 13 | ### CocoaPods 14 | Add `pod 'AAPullToRefresh'` to your Podfile. 15 | 16 | ### Manually 17 | 18 | 1. Copy `AAPullToRefresh` directory to your project. 19 | 20 | ## Usage 21 | 22 | #import "AAPullToRefresh.h" 23 | ... 24 | AAPullToRefresh *tv = [self.scrollView addPullToRefreshPosition:AAPullToRefreshPositionTop actionHandler:^(AAPullToRefresh *v){ 25 | // do something... 26 | // then must call stopIndicatorAnimation method. 27 | [v performSelector:@selector(stopIndicatorAnimation) withObject:nil afterDelay:1.0f]; 28 | }]; 29 | 30 | ### Customization 31 | #### Property 32 | You can customize below properties. 33 | 34 | tv.imageIcon = [UIImage imageNamed:@"launchpad"]; 35 | tv.borderColor = [UIColor whiteColor]; 36 | tv.borderWidth = 3.0f; 37 | tv.threshold = 60.0f; 38 | tv.showPullToRefresh = NO; // also remove KVO observer if set to NO. 39 | 40 | #### Method 41 | - (void)manuallyTriggered; // Manually trigger the block. 42 | - (void)setSize:(CGSize)size; // Zoom in/out size. 43 | 44 | ## LICENSE 45 | MIT 46 | --------------------------------------------------------------------------------