//
// UIDynamicAnimator.h
// UIKit
//
// Copyright (c) 2012-2015 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
// 动画管理者
NS_CLASS_AVAILABLE_IOS(7_0) @interface UIDynamicAnimator: NSObject
// When you initialize a dynamic animator with this method, you should only associates views with your behaviors.
// the behaviors (and their dynamic items) that you add to the animator employ the reference view’s coordinate system.
// 通过传递引用视图的方式来创建动画管理者
// 引用视图只是给动画执行者提供坐标体系
- (instancetype)initWithReferenceView:(UIView *)view NS_DESIGNATED_INITIALIZER;
// 添加动画行为
- (void)addBehavior:(UIDynamicBehavior *)behavior;
// 移除动画行为
- (void)removeBehavior:(UIDynamicBehavior *)behavior;
// 移除所有动画行为
- (void)removeAllBehaviors;
// 动画执行者引用的 View
@property (nullable, nonatomic, readonly) UIView *referenceView;
// 获取所有的动画行为
@property (nonatomic, readonly, copy) NSArray<__kindof UIDynamicBehavior*> *behaviors;
// Returns the dynamic items associated with the animator’s behaviors that intersect a specified rectangle
// 获取某个范围内的 item
- (NSArray<id<UIDynamicItem>> *)itemsInRect:(CGRect)rect;
// Update the item state in the animator if an external change was made to this item
// 更新项目状态的动画师如果外部改变了这个项目
- (void)updateItemUsingCurrentState:(id <UIDynamicItem>)item;
// 是否正在运行
@property (nonatomic, readonly, getter = isRunning) BOOL running;
// 获取已经执行的时间
#if UIKIT_DEFINE_AS_PROPERTIES
@property (nonatomic, readonly) NSTimeInterval elapsedTime;
#else
// elapsed : 过去的,已经消失的。
- (NSTimeInterval)elapsedTime;
#endif
// 动画管理者代理
@property (nullable, nonatomic, weak) id <UIDynamicAnimatorDelegate> delegate;
@end
// collectionView 附加的方法
@interface UIDynamicAnimator (UICollectionViewAdditions)
// When you initialize a dynamic animator with this method, you should only associate collection view layout attributes with your behaviors.
// The animator will employ thecollection view layout’s content size coordinate system.
// 通过传递布局对象的方式来创建动画管理对象
// 主要是用来提供一个坐标体系
- (instancetype)initWithCollectionViewLayout:(UICollectionViewLayout *)layout;
// The three convenience methods returning layout attributes (if associated to behaviors in the animator) if the animator was configured with collection view layout
- (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
UIDynamicAnimator
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 2016年,从大三到大四,很多人都说,大三大四是很容易迷茫的一个时期,然而我似乎都没有时间来迷茫。每次有一点迷茫的...
- 文章开头:本文是Mandy权老师发表在产品壹佰的文章(http://www.chanpin100.com/arti...