UIDynamicBehavior
2016-07-13 本文已影响26人
Laughingg
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 }
}