用POP動畫模擬真實秒鐘擺動效果

2021-09-23 21:47:59 字數 2457 閱讀 4260

用pop動畫模擬真實秒鐘擺動效果

靜態圖:

動畫圖:

此處用到了pop中的spring系列動畫,現提供原始碼如下:

secondclockview.h 與 secondclockview.m

//

// secondclockview.h

// youxianmingclock

//// created by youxianming on 14-10-12.

//#import @inte***ce secondclockview : uiview

/** * use in conjunction with 'springspeed' to change animation effect. values are converted into corresponding dynamics constants. defined as a value in the range [0, 20]. defaults to 18.

*/@property (nonatomic, assign) cgfloat springbounciness;

/** * the mass used in the dynamics simulation.

*/@property (nonatomic, assign) cgfloat dynamicsmass;

/** * use in conjunction with 'springbounciness' to change animation effect. values are converted into corresponding dynamics constants. defined as a value in the range [0, 20]. defaults to 18.

*/@property (nonatomic, assign) cgfloat springspeed;

/** * 給與時間進行的動畫

* * @param second 當前秒

*/- (void)startanimationwithsecond:(float)second;

@end

//

// secondclockview.m

// youxianmingclock

//// created by youxianming on 14-10-12.

//#import "secondclockview.h"

#import "pop.h"

/** * 將角度轉換為弧度

* * @param d 角度

* * @return 弧度

*/#define degrees__to__radians(d) ((d) * m_pi / 180.f)

@inte***ce secondclockview ()

@end

@implementation secondclockview

- (void)startanimationwithsecond:(float)second

springanimation.tovalue = @(degrees__to__radians((360)/60.f)*second + degrees__to__radians(-90));

springanimation.springbounciness = (_springbounciness > 0 && _springbounciness <= 20)?_springbounciness:18.f;

springanimation.dynamicsmass = (_dynamicsmass > 0)?_dynamicsmass:1.5f;

springanimation.springspeed = (_springspeed > 0 && _springspeed <= 20)?_springspeed:18.f;

[self.layer pop_addanimation:springanimation forkey:nil];

}@end

使用時候的情形

使用的時候請引入pop庫

Python爬蟲模擬真實登入案例系列之十二

import time import requests from bs4 import beautifulsoup defcaptcha data with open captcha.png wb as f f.write data 返回輸入的驗證碼字串 return input 請輸入驗證碼 de...

實驗室測試模擬真實網路環境方法

我們的專案,可能會涉及到各種網路環境,比如通過家庭寬頻接入 通過手機接入,這些環境相對於我們測試時候使用的網路環境要複雜的多,如何模擬現網可能出現的各種網路情況,使得我們的程式,在各種環境下都能夠正常的執行,是我們需要解決的難題。1具體操作 模擬延遲傳輸 tc qdisc add dev eth0 ...

本週遊戲一點想法 模擬真實格鬥

一杯濁酒盡餘杯,今宵別夢寒。這週有個一起住了三年的朋友回海南了,心情低落的很。朋友離開的那天,凌晨4點才睡著,當時就想如果有個遊戲能夠提供全息立體場景,就可以不用這麼傷心了。當然,立體全息近期是不可能的了,我就想既然看的不行,聽得行嗎?我和朋友約著一起玩個遊戲,並且可以無限制的聊天就好了,像yy一樣...