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

#import "YHAnimationProxy.h"
#import "YHShorthand.h"

/**
 *  基础类动画
 */
@interface YHBasicAnimation : YHAnimationProxy
/**
 *  时长
 */
@property (assign, nonatomic) CFTimeInterval duration;
/**
 *  时间函数
 */
@property (strong, nonatomic) CAMediaTimingFunction *timingFunction;

@end

/**
 *  NSObject扩展
    使用下面4个方法可以直接快速创建一个YHBasicAnimation实例
 */
@interface NSObject (YHBasicAnimation)

@property (assign, nonatomic) CFTimeInterval pop_duration;
/**
 *  获取线性动画的实例
 *
 *  @return 动画代理实例 YHBasicAnimation
 */
- (instancetype)pop_linear;
/**
 *  获取淡入动画的实例
 *
 *  @return 动画代理实例 YHBasicAnimation
 */
- (instancetype)pop_easeIn;
/**
 *  获取淡出动画的实例
 *
 *  @return 动画代理实例 YHBasicAnimation
 */
- (instancetype)pop_easeOut;
/**
 *  获取淡入淡出动画的实例
 *
 *  @return 动画代理实例 YHBasicAnimation
 */
- (instancetype)pop_easeInEaseOut;

@end

#pragma mark - 简写模式
#ifdef YHANIMATE_SHORTHAND

@interface NSObject (YHBasicAnimation_DropPrefix)

@property (assign, nonatomic) CFTimeInterval duration;

- (instancetype)linear;
- (instancetype)easeIn;
- (instancetype)easeOut;
- (instancetype)easeInEaseOut;

@end

@implementation NSObject (YHBasicAnimation_DropPrefix)

YHSHORTHAND_PROPERTY(duration, Duration, CFTimeInterval)
YHSHORTHAND_GETTER(linear, instancetype)
YHSHORTHAND_GETTER(easeIn, instancetype)
YHSHORTHAND_GETTER(easeOut, instancetype)
YHSHORTHAND_GETTER(easeInEaseOut, instancetype)

@end

#endif