UIDynamicBehavior

import Foundation
import UIKit

//
//  UIDynamicBehavior.h
//  UIKit
//
//  Copyright (c) 2012-2015 Apple Inc. All rights reserved.
//

@available(iOS 9.0, *)
public enum UIDynamicItemCollisionBoundsType : UInt {
    
    case Rectangle
    case Ellipse // radii will be determined from the items bounds width, height
    case Path
}

public protocol UIDynamicItem : NSObjectProtocol {
    
    public var center: CGPoint { get set }
    public var bounds: CGRect { get }
    public var transform: CGAffineTransform { get set }
    
    /**
     The collision type represents how the dynamics system will evaluate collisions with 
     respect to the dynamic item. defaults to UIDynamicItemCollisionBoundsTypeRectangle
     */
    @available(iOS 9.0, *)
    optional public var collisionBoundsType: UIDynamicItemCollisionBoundsType { get }
    
    /**
     The path must represent a convex polygon with counter clockwise winding and no self intersection. 
     The point (0,0) in the path corresponds to the dynamic item's center.
     */
    @available(iOS 9.0, *)
    optional public var collisionBoundingPath: UIBezierPath { get }
}

@available(iOS 9.0, *)
public class UIDynamicItemGroup : NSObject, UIDynamicItem {
    
    public init(items: [UIDynamicItem])
    
    public var items: [UIDynamicItem] { get }
}

@available(iOS 7.0, *)
public class UIDynamicBehavior : NSObject {
    
    // 添加子行为(主要是让他自定义 behavior )
    public func addChildBehavior(behavior: UIDynamicBehavior)
    // 移除子行为
    public func removeChildBehavior(behavior: UIDynamicBehavior)
    
    // 获取所有的子行为
    public var childBehaviors: [UIDynamicBehavior] { get }
    
    // When running, the dynamic animator calls the action block on every animation step.
    // 当运行,动态动画器调用动作块在每个动画的步骤。
    // 行为
    public var action: (() -> Void)?
    
    public func willMoveToAnimator(dynamicAnimator: UIDynamicAnimator?) // nil when being removed from an animator
    
    // 获取动画执行者
    public var dynamicAnimator: UIDynamicAnimator? { get }
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 文/林小白 有不少人说,最好的工作就是钱多事少离家近的工作。在不少人眼里,他人的工作总是比自己的好,可谓是得不到的...
    Nicole林小白阅读 1,029评论 0 9
  • 跃迁目录 推荐序 俞敏洪:用自己的步伐丈量这个时代 罗振宇:这个时代需要什么样的学习? 万维钢:鸟类学家想告诉鸟的...
    lianchao阅读 678评论 0 1
  • 是的,为什么要为他人作嫁衣,经营自我,还是总是蹭大腿。去经历自我,才会有真实的感受力。不只是看电影,而是出...
    TS小西阅读 168评论 0 0
  • 四月跨过了和煦将尽 晨起的强光普照穿透 一路一路的树荫 林间的长尾燕啼鸣 草滩深处有虫 随声附和 想煮一壶香茗 闻...
    浩宇_90阅读 168评论 0 0

友情链接更多精彩内容