#if USE_UIKIT_PUBLIC_HEADERS || !__has_include(<UIKitCore/UIDynamicItemBehavior.h>)
//
// UIDynamicItemBehavior.h
// UIKit
//
// Copyright (c) 2012-2018 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIDynamicBehavior.h>
NS_ASSUME_NONNULL_BEGIN
#pragma mark - 动态行为Item管理器 Class
#pragma mark -
/*
概述
- 一个或多个动态项的基本动态动画配置
- 动态项行为的一个值得注意和常见的用途是将速度赋予动态项以匹配用户手势的结束速度
*/
NS_CLASS_AVAILABLE_IOS(7_0) @interface UIDynamicItemBehavior : UIDynamicBehavior
#pragma mark |实例化|
- (instancetype)initWithItems:(NSArray<id <UIDynamicItem>> *)items NS_DESIGNATED_INITIALIZER;
// 添加动态Item
- (void)addItem:(id <UIDynamicItem>)item;
// 移除指定动态Item
- (void)removeItem:(id <UIDynamicItem>)item;
/// 获取所有已添加的动态Item
@property (nonatomic, readonly, copy) NSArray<id <UIDynamicItem>> *items;
#pragma mark |基本配置|
/// 弹性系数(介于0-1之间)
@property (readwrite, nonatomic) CGFloat elasticity;
/// 摩擦力(两个象湖运动的Item的线性阻力;0表示无摩擦)
@property (readwrite, nonatomic) CGFloat friction;
/// 密度(默认:1)
@property (readwrite, nonatomic) CGFloat density;
/// 阻尼(随着时间的推移降低了线性速度;0表示无阻尼)
@property (readwrite, nonatomic) CGFloat resistance;
/// 角度阻尼(0表示无角度阻尼)
@property (readwrite, nonatomic) CGFloat angularResistance;
/// 电荷(物体与电场和磁场相互作用的程度;默认:0.0)
@property (readwrite, nonatomic) CGFloat charge NS_AVAILABLE_IOS(9_0);
/// 锚定(物体是否定到当前位置,类似碰撞边界效果,不做碰撞移动;默认:NO)
@property (nonatomic, getter = isAnchored) BOOL anchored NS_AVAILABLE_IOS(9_0);
/// 是否允许物体旋转(默认:YES)
@property (readwrite, nonatomic) BOOL allowsRotation;
#pragma mark |线性速度|
// 为Item添加线性速度(线性速度以每秒点数表示;负值会将线速度降低指定的量;默认:0)
- (void)addLinearVelocity:(CGPoint)velocity forItem:(id <UIDynamicItem>)item;
// 获取指定Item的线性速度
- (CGPoint)linearVelocityForItem:(id <UIDynamicItem>)item;
#pragma mark |角速度|
// 为Item添加角速度(角速度以弧度/秒表示;负值会将角速度降低指定的量;默认:0)
- (void)addAngularVelocity:(CGFloat)velocity forItem:(id <UIDynamicItem>)item;
// 获取指定Item的角速度
- (CGFloat)angularVelocityForItem:(id <UIDynamicItem>)item;
@end
NS_ASSUME_NONNULL_END
#else
#import <UIKitCore/UIDynamicItemBehavior.h>
#endif
网友评论