美文网首页
UIDynamicAnimator

UIDynamicAnimator

作者: Laughingg | 来源:发表于2016-07-13 15:19 被阅读214次
    //
    //  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

          本文链接:https://www.haomeiwen.com/subject/kxosjttx.html