//
// UIDynamicBehavior.h
// UIKit
//
// Copyright (c) 2012-2015 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, // 橢圓 radii will be determined from the items bounds width, height
UIDynamicItemCollisionBoundsTypePath // 路徑
} NS_ENUM_AVAILABLE_IOS(9_0);
// UIDynamicItem 協(xié)議, 所有的 UI 控件都遵守了這個協(xié)議
@protocol UIDynamicItem <NSObject>
@property (nonatomic, readwrite) CGPoint center;
@property (nonatomic, readonly) CGRect bounds;
@property (nonatomic, readwrite) CGAffineTransform transform;
// 可選的
@optional
/**
The collision type represents how the dynamics system will evaluate collisions with
respect to the dynamic item. defaults to UIDynamicItemCollisionBoundsTypeRectangle
*/
@property (nonatomic, readonly) UIDynamicItemCollisionBoundsType collisionBoundsType NS_AVAILABLE_IOS(9_0);
/**
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.
*/
@property (nonatomic, readonly) UIBezierPath *collisionBoundingPath NS_AVAILABLE_IOS(9_0);
@end
// item group
NS_CLASS_AVAILABLE_IOS(9_0) @interface UIDynamicItemGroup : NSObject <UIDynamicItem>
// 通過 item 數(shù)組進行實例化
- (instancetype)initWithItems:(NSArray<id <UIDynamicItem>> *)items;
// 獲取 item 數(shù)組
@property (nonatomic, readonly, copy) NSArray<id <UIDynamicItem>> *items;
@end
// 行為類
NS_CLASS_AVAILABLE_IOS(7_0) @interface UIDynamicBehavior : NSObject
// ****** 下面這些方法只能在 自定義的 UIDynamicBehavior 中使用 UI 中定義的 Behavior 是不能使用的 ******
// 添加子行為 到這個行為對象( 這種方式主要是進行行為自定義)
/*
behavior 對象如果已經(jīng)添加到了夫 behavior 中,或者 behavior 為 nil 儡蔓。
那么這個方法的調(diào)用就被忽略
這個方法只能在 自定義的 UIDynamicBehavior 子類中調(diào)用
*/
- (void)addChildBehavior:(UIDynamicBehavior *)behavior;
// 移除子行為 (只能在自定義的類中使用)
- (void)removeChildBehavior:(UIDynamicBehavior *)behavior;
// 獲取所有的子行為
// 這個方法只能在 自定義的 UIDynamicBehavior 子類中調(diào)用
@property (nonatomic, readonly, copy) NSArray<__kindof UIDynamicBehavior *> *childBehaviors;
// When running, the dynamic animator calls the action block on every animation step.
// 運行時,動態(tài)動畫器調(diào)用動作塊在每個動畫的步驟。
@property (nullable, nonatomic,copy) void (^action)(void);
// behavior 被添加或者被移除的時候會調(diào)用這個方法
// 這個方法是用來重載的 用來響應 behavior tree 在 animator 中的改變
- (void)willMoveToAnimator:(nullable UIDynamicAnimator *)dynamicAnimator; // nil when being removed from an animator
// 獲取動畫管理者
@property (nullable, nonatomic, readonly) UIDynamicAnimator *dynamicAnimator;
@end
NS_ASSUME_NONNULL_END
UIDynamicBehavior
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
- 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來越平,“玉大人频蛔,你說我怎么就攤上這事∏嘏眩” “怎么了晦溪?”我有些...
- 文/不壞的土叔 我叫張陵,是天一觀的道長挣跋。 經(jīng)常有香客問我三圆,道長,這世上最難降的妖魔是什么避咆? 我笑而不...
- 正文 為了忘掉前任舟肉,我火速辦了婚禮,結(jié)果婚禮上查库,老公的妹妹穿的比我還像新娘路媚。我一直安慰自己,他們只是感情好樊销,可當我...
- 文/花漫 我一把揭開白布整慎。 她就那樣靜靜地躺著,像睡著了一般现柠。 火紅的嫁衣襯著肌膚如雪院领。 梳的紋絲不亂的頭發(fā)上,一...
- 文/蒼蘭香墨 我猛地睜開眼饮怯,長吁一口氣:“原來是場噩夢啊……” “哼闰歪!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起蓖墅,我...
- 正文 年R本政府宣布,位于F島的核電站膘掰,受9級特大地震影響章姓,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜识埋,卻給世界環(huán)境...
- 文/蒙蒙 一凡伊、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧窒舟,春花似錦系忙、人聲如沸。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至洁墙,卻和暖如春蛹疯,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背热监。 一陣腳步聲響...
推薦閱讀更多精彩內(nèi)容
- 公元前354年(周顯王十五年),趙國進攻魏國的盟國衛(wèi)國邻吭,奪取了漆及富丘兩地(均在今河南長垣),此舉招致了中原霸主魏...