美文网首页< UIKit >
UIDynamicBehavior.h

UIDynamicBehavior.h

作者: zhYx_ | 来源:发表于2019-06-25 10:03 被阅读0次
    
    #if USE_UIKIT_PUBLIC_HEADERS || !__has_include(<UIKitCore/UIDynamicBehavior.h>)
    //
    //  UIDynamicBehavior.h
    //  UIKit
    //
    //  Copyright (c) 2012-2018 Apple Inc. All rights reserved.
    //
    
    #import <Foundation/Foundation.h>
    #import <UIKit/UIGeometry.h>
    
    NS_ASSUME_NONNULL_BEGIN
    @class UIDynamicAnimator;
    @class UIBezierPath;
    
    
    
    /* 碰撞边界类型 <枚举> */
    typedef NS_ENUM(NSUInteger, UIDynamicItemCollisionBoundsType) {
        UIDynamicItemCollisionBoundsTypeRectangle,  /// 矩形碰撞边界
        UIDynamicItemCollisionBoundsTypeEllipse,    /// 椭圆碰撞边界 (椭圆的形状由项目边界属性的宽度和高度决定)
        UIDynamicItemCollisionBoundsTypePath        /// 基于路径的碰撞边界 (此类型shape是存储在Item的collisionBoundingPath属性中的UIBezierPath对象)
    } NS_ENUM_AVAILABLE_IOS(9_0);
    
    
    
    ///!!!: 动态项设置 <协议>
    @protocol UIDynamicItem <NSObject>
    
    /// 中心点
    @property (nonatomic, readwrite) CGPoint center;
    /// 尺寸
    @property (nonatomic, readonly) CGRect bounds;
    /// 旋转
    @property (nonatomic, readwrite) CGAffineTransform transform;
    
    @optional
    /// 碰撞边界类型 (默认:UIDynamicItemCollisionBoundsTypeRectangle)
    @property (nonatomic, readonly) UIDynamicItemCollisionBoundsType collisionBoundsType NS_AVAILABLE_IOS(9_0);
    /// 贝塞尔路径碰撞边界
    @property (nonatomic, readonly) UIBezierPath *collisionBoundingPath NS_AVAILABLE_IOS(9_0);
    
    @end
    
    
    
    
    
    #pragma mark - 一组动态项 Class
    #pragma mark -
    NS_CLASS_AVAILABLE_IOS(9_0) @interface UIDynamicItemGroup : NSObject <UIDynamicItem>
    
    #pragma mark |实例化|
    - (instancetype)initWithItems:(NSArray<id <UIDynamicItem>> *)items;
    
    /// 动态项组所包含的所有动态项
    @property (nonatomic, readonly, copy) NSArray<id <UIDynamicItem>> *items;
    
    @end
    
    
    
    
    
    #pragma mark - 动态行为管理器 Class
    #pragma mark -
    /*
     概述
     - 对一个或多个动态项目赋予行为配置的对象,用于参与2D动画
     */
    NS_CLASS_AVAILABLE_IOS(7_0) @interface UIDynamicBehavior : NSObject
    
    // 添加自定义动态行为
    - (void)addChildBehavior:(UIDynamicBehavior *)behavior;
    // 删除指定动态行为
    - (void)removeChildBehavior:(UIDynamicBehavior *)behavior;
    
    /// 获取所有已添加的动态行为
    @property (nonatomic, readonly, copy) NSArray<__kindof UIDynamicBehavior *> *childBehaviors;
    /// 动态行为每个动画执行步骤的回调
    @property (nullable, nonatomic,copy) void (^action)(void);
    
    // 添加/删除动态行为时调用(删除动态行为时为nil)
    - (void)willMoveToAnimator:(nullable UIDynamicAnimator *)dynamicAnimator;
    
    /// 与动态行为关联的动态动画管理器
    @property (nullable, nonatomic, readonly) UIDynamicAnimator *dynamicAnimator;
    
    @end
    
    
    
    
    
    NS_ASSUME_NONNULL_END
    #else
    #import <UIKitCore/UIDynamicBehavior.h>
    #endif
    
    

    相关文章

      网友评论

        本文标题:UIDynamicBehavior.h

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