UIDynamicAnimator.h
2019-06-24 本文已影响0人
zhYx_
#if USE_UIKIT_PUBLIC_HEADERS || !__has_include(<UIKitCore/UIDynamicAnimator.h>)
//
// UIDynamicAnimator.h
// UIKit
//
// Copyright (c) 2012-2018 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIView.h>
#import <UIKit/UICollectionViewLayout.h>
NS_ASSUME_NONNULL_BEGIN
@class UIDynamicBehavior;
@class UIDynamicAnimator;
///!!!: 代理 <协议>
@protocol UIDynamicAnimatorDelegate <NSObject>
@optional
// 动画管理器将要恢复运行
- (void)dynamicAnimatorWillResume:(UIDynamicAnimator *)animator;
// 动画管理器已经暂停
- (void)dynamicAnimatorDidPause:(UIDynamicAnimator *)animator;
@end
#pragma mark - 动态动画管理器 Class
#pragma mark -
/*
概述
-
*/
NS_CLASS_AVAILABLE_IOS(7_0) @interface UIDynamicAnimator: NSObject
#pragma mark |实例化|
/**
实例化
@param view 参照视图(动画要添加到的父视图)
@return UIDynamicAnimator
*/
- (instancetype)initWithReferenceView:(UIView *)view NS_DESIGNATED_INITIALIZER;
// 添加动态特性
- (void)addBehavior:(UIDynamicBehavior *)behavior;
// 删除指定的动态特性
- (void)removeBehavior:(UIDynamicBehavior *)behavior;
// 删除所有动态特性
- (void)removeAllBehaviors;
/// 参照视图
@property (nullable, nonatomic, readonly) UIView *referenceView;
/// 所有动态特性
@property (nonatomic, readonly, copy) NSArray<__kindof UIDynamicBehavior*> *behaviors;
// 获取指定范围内的动态项
- (NSArray<id<UIDynamicItem>> *)itemsInRect:(CGRect)rect;
// 更改指定动态项的状态(如动态项的位置或旋转)
- (void)updateItemUsingCurrentState:(id <UIDynamicItem>)item;
/// 动画管理器是否正在运行
@property (nonatomic, readonly, getter = isRunning) BOOL running;
/* 动画管理器已运行的时间 */
#if UIKIT_DEFINE_AS_PROPERTIES
@property (nonatomic, readonly) NSTimeInterval elapsedTime;
#else
- (NSTimeInterval)elapsedTime;
#endif
/// 代理
@property (nullable, nonatomic, weak) id <UIDynamicAnimatorDelegate> delegate;
@end
#pragma mark - 动态动画管理器附加方法 <分类>
@interface UIDynamicAnimator (UICollectionViewAdditions)
#pragma mark |实例化|
/**
实例化
@param layout 使用集合视图的布局(动画管理器将使用集合视图布局的内容大小坐标系)
@return UIDynamicAnimator
*/
- (instancetype)initWithCollectionViewLayout:(UICollectionViewLayout *)layout;
// 获取指定索引上Cell的布局属性
- (nullable UICollectionViewLayoutAttributes *)layoutAttributesForCellAtIndexPath:(NSIndexPath *)indexPath;
// 获取指定索引指定补充视图的布局属性
- (nullable UICollectionViewLayoutAttributes *)layoutAttributesForSupplementaryViewOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath;
// 获取指定索引指定修饰视图的布局属性
- (nullable UICollectionViewLayoutAttributes *)layoutAttributesForDecorationViewOfKind:(NSString *)decorationViewKind atIndexPath:(NSIndexPath *)indexPath;
@end
NS_ASSUME_NONNULL_END
#else
#import <UIKitCore/UIDynamicAnimator.h>
#endif