Skip to content

Instantly share code, notes, and snippets.

@lancy
Created November 10, 2014 14:29
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save lancy/4982d0f6f708133cc8e1 to your computer and use it in GitHub Desktop.
Save lancy/4982d0f6f708133cc8e1 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>
@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