YHAnimationGroup.h 1.44 KB
//
//  YHAnimationGroup.h
//  YHAnimationDemo
//
//  Created by gaoqiang xu on 2/9/15.
//  Copyright (c) 2015 gaoqiang. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "POP.h"

/**
 *  动画群类
 */
@interface YHAnimationGroup : NSObject

/**
 *  是否完成
 */
@property (assign, nonatomic, getter = isFinished, readonly) BOOL finished;
/**
 *  完成回调
 */
@property (copy, nonatomic) void (^completionBlock)(BOOL finished);

/**
 *  添加POP动画
 *
 *  @param animation POPAnimation实例
 */
- (void)addAnimation:(POPAnimation *)animation;
/**
 *  
 *
 *  @param animation POPAnimation实例
 *  @param finished  标记是否完成
 */
- (void)removeAnimation:(POPAnimation *)animation finished:(BOOL)finished;

@end

/**
 *  NSObject扩展,快速使用动画群做动画
 */
@interface NSObject (YHAnimationGroup)

/**
 *  使用动画群YHAnimationGroup做动画
 *
 *  @param animations 动画代码
 *  @param completion 完成回调
 */
+ (void)pop_animate:(void (^)(void))animations completion:(void (^)(BOOL finished))completion;

@end

#ifdef YHANIMATE_SHORTHAND

@interface NSObject (YHAnimationGroup_DropPrefix)

+ (void)animate:(void (^)(void))animations completion:(void (^)(BOOL finished))completion;

@end

@implementation NSObject (YHAnimationGroup_DropPrefix)

+ (void)animate:(void (^)(void))animations completion:(void (^)(BOOL finished))completion {
    [self pop_animate:animations completion:completion];
}

@end

#endif