Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Huang-Libo/8296143f2c594a87b5b27ec7230b2191 to your computer and use it in GitHub Desktop.
Save Huang-Libo/8296143f2c594a87b5b27ec7230b2191 to your computer and use it in GitHub Desktop.
YTKAnimatingRequestAccessory
//
// YTKAnimatingRequestAccessory.h
// Ape_uni
//
// Created by Chenyu Lan on 10/30/14.
// Copyright (c) 2014 Fenbi. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <YTKBaseRequest.h>
@interface YTKAnimatingRequestAccessory : NSObject <YTKRequestAccessory>
@property(nonatomic, weak) UIView *animatingView;
@property(nonatomic, strong) NSString *animatingText;
- (id)initWithAnimatingView:(UIView *)animatingView;
- (id)initWithAnimatingView:(UIView *)animatingView animatingText:(NSString *)animatingText;
+ (id)accessoryWithAnimatingView:(UIView *)animatingView;
+ (id)accessoryWithAnimatingView:(UIView *)animatingView animatingText:(NSString *)animatingText;
@end
//
// YTKAnimatingRequestAccessory.m
// Ape_uni
//
// Created by Chenyu Lan on 10/30/14.
// Copyright (c) 2014 Fenbi. All rights reserved.
//
#import "YTKAnimatingRequestAccessory.h"
#import "YTKAlertUtils.h"
@implementation YTKAnimatingRequestAccessory
- (id)initWithAnimatingView:(UIView *)animatingView animatingText:(NSString *)animatingText {
self = [super init];
if (self) {
_animatingView = animatingView;
_animatingText = animatingText;
}
return self;
}
- (id)initWithAnimatingView:(UIView *)animatingView {
self = [super init];
if (self) {
_animatingView = animatingView;
}
return self;
}
+ (id)accessoryWithAnimatingView:(UIView *)animatingView {
return [[self alloc] initWithAnimatingView:animatingView];
}
+ (id)accessoryWithAnimatingView:(UIView *)animatingView animatingText:(NSString *)animatingText {
return [[self alloc] initWithAnimatingView:animatingView animatingText:animatingText];
}
- (void)requestWillStart:(id)request {
if (_animatingView) {
[YTKAlertUtils showLoadingAlertView:_animatingText inView:_animatingView];
}
}
- (void)requestWillStop:(id)request {
if (_animatingView) {
[YTKAlertUtils hideLoadingAlertView:_animatingView];
}
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment