iOS - 動力行為

#pragma mark---知識點(diǎn)---

1、簡介:屬于UIKit

(1)什么是動力行為?

模擬真實(shí)世界中力學(xué)相關(guān)的動畫和交互系統(tǒng)

(2)可以實(shí)現(xiàn)的效果

重力、碰撞、吸附、推動、捕捉效果,并且可以組合

(3)ios9

UIDynamicItemGroup可以統(tǒng)一給一組元素添加動力行為

(4)ios9可以定義成以球形的方式去接觸另一個邊境或元素

2、類名介紹

(1)UIDynamicAnimation動力效果的動畫播放者

《1》initWithReferenceView初始化動力效果播放者并制定參考視圖

《2》addBehavior:添加動力行為

《3》removeBehavior:移除某個動力行為

《4》removeAllBehaviors移除所有動力行為

《5》delegate代理

(2)動力效果的動畫行為

《1》UIGravityBehavior重力效果行為會影響到動力元素的屬性(frame)

1.initWithItems:初始化重力效果行為并指定作用對象

2.addItem:添加重力效果作用對象

3.removeItem:移除作用對象

4.gravityDirection重力的方向

CGVector:表示矢量的結(jié)構(gòu)體值:0-1

x:橫向重力

y:豎向重力

受加速度的影響

5.Angle:更改重力效果的角度

6.magnitude:加速度的級別1.0代表加速度是1000points /second2

7.setAngle:magnitude:設(shè)置重力方向的角度和速度

《2》UICollisionBehavior碰撞行為

(1)initWithItems:

(2)collisionMode:

UICollisionBehaviorModeItems元素碰撞

UICollisionBehaviorModeBoundaries邊境碰撞

UICollisionBehaviorModeEverything所有都可以碰撞

(3)collisionDelegate碰撞效果的代理

元素碰撞的時(shí)候調(diào)用

- (void)collisionBehavior:(UICollisionBehavior *)behavior

beganContactForItem:(id)item1 withItem:(id)item2 atPoint:(CGPoint)p

- (void)collisionBehavior:(UICollisionBehavior *)behavior

endedContactForItem:(id)item1 withItem:(id)item2

邊境碰撞的時(shí)候調(diào)用

- (void)collisionBehavior:(UICollisionBehavior*)behavior

beganContactForItem:(id)item withBoundaryIdentifier:(nullableid)identifier atPoint:(CGPoint)p

- (void)collisionBehavior:(UICollisionBehavior*)behavior

endedContactForItem:(id)item withBoundaryIdentifier:(nullableid)identifier

(4)addBoundaryWithIdentifier:forPath:添加路徑為邊境

(5)- (nullableUIBezierPath *)boundaryWithIdentifier:(id)identifier

(6)addBoundaryWithIdentifier:fromPoint:toPoint:添加一條線為邊境

(7)removeBoundaryWithIdentifier移除

(8)translatesReferenceBoundsIntoBoundary是否以參照視圖作為邊界

(9)setTranslatesReferenceBoundsIntoBoundaryWithInsets:設(shè)置參照視圖的內(nèi)間距

《3》UIPushBehavior

《4》UISnapBehavior

《5》UIAttachmentBehavior

《6》UIDynamicItemBehavior

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容