Animation and Core Motion 0718

A lazy property doesn't get initialized until someone accesses it. Things initialized this way can't be constant.

Lazy means that the initialization here doesn't happen until someone calls this var.

We are initializing. Can we refer to self when we are initializing? No, because self is not fully initialized yet. So we can get around this through with our favorite lazy var. So now, it's not going to initialize this until someone ask for the animator.

Every time we add a drop down, we are going to want to add it to the behavior. That makes that gravity start affecting that drop. We created the animator, we created our behavior, we added the behavior to the animator, and then we added items that we wanted affected by that behavior to the behavior.

When we create a subclass, we are obviously going to have an init.

We are going to call remove completed row when all the bouncing stops. When our dynamic animation engine pauses, then we are going to try to remove a row. Cuz if things are still bouncing, we can't really be removing rows while things are still bouncing. So when things have settled down, then we'll try and remove a complete row if we can.

How do we find out the things have stopped?

We use a dynamic animator's delegate. The dynamic animator will tell its delegate when things have paused. When things have stasis. So we are going to have to do the same trick here that we did with these other ones, and use a closure. Create this because we just have the delegate of it.

LayoutSubviews is the method in the view that's called whenever the system wants the view to lay it's subviews out.

When a UI view's bounds change, what gets called? ?Layout subviews. It doesn't have a view did layout subviews, it has the actual layout subviews that lays the subviews out. So that's a good place to put this thing in the middle. Because layout subviews is going to get called every single time. The bounds change. So that's layou subviews.

Always think object-oriented when we are building an iOS.

What I'm going to do instead to draw all that little circle, is I'm going to create a new UIView subclass. And all this UIView subclass I'm going to create does is it knows how to draw a bezier path in itself. It's just a generic bezier path drawing view. And It's really generic. It has nothing to do with DropIt. I could well end up using this in some other app.

Action is a closure that we can set. It could get called every time that behavior acts.

Core motion is an object-oriented API to get at the motion sensing hardware on our device. So that's accelerometer, the gyro, magnetometer, those kinds of things.

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末竿屹,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子拱燃,更是在濱河造成了極大的恐慌,老刑警劉巖召嘶,帶你破解...
    沈念sama閱讀 217,542評論 6 504
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件哮缺,死亡現(xiàn)場離奇詭異,居然都是意外死亡铛只,警方通過查閱死者的電腦和手機(jī)糠溜,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,822評論 3 394
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來蜕着,“玉大人红柱,你說我怎么就攤上這事”荆” “怎么了?”我有些...
    開封第一講書人閱讀 163,912評論 0 354
  • 文/不壞的土叔 我叫張陵宽闲,是天一觀的道長握牧。 經(jīng)常有香客問我,道長览徒,這世上最難降的妖魔是什么颂龙? 我笑而不...
    開封第一講書人閱讀 58,449評論 1 293
  • 正文 為了忘掉前任纽什,我火速辦了婚禮躲叼,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘让蕾。我一直安慰自己或听,他們只是感情好探孝,可當(dāng)我...
    茶點故事閱讀 67,500評論 6 392
  • 文/花漫 我一把揭開白布再姑。 她就那樣靜靜地躺著找御,像睡著了一般。 火紅的嫁衣襯著肌膚如雪霎桅。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,370評論 1 302
  • 那天遇革,我揣著相機(jī)與錄音揭糕,去河邊找鬼。 笑死揪漩,一個胖子當(dāng)著我的面吹牛吏口,可吹牛的內(nèi)容都是我干的奄容。 我是一名探鬼主播产徊,決...
    沈念sama閱讀 40,193評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼舟铜,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了谆刨?” 一聲冷哼從身側(cè)響起归斤,我...
    開封第一講書人閱讀 39,074評論 0 276
  • 序言:老撾萬榮一對情侶失蹤官册,失蹤者是張志新(化名)和其女友劉穎难捌,沒想到半個月后鸦难,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體根吁,經(jīng)...
    沈念sama閱讀 45,505評論 1 314
  • 正文 獨居荒郊野嶺守林人離奇死亡击敌,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,722評論 3 335
  • 正文 我和宋清朗相戀三年拴事,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片衡瓶。...
    茶點故事閱讀 39,841評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡牲证,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出十厢,到底是詐尸還是另有隱情,我是刑警寧澤蛮放,帶...
    沈念sama閱讀 35,569評論 5 345
  • 正文 年R本政府宣布奠宜,位于F島的核電站,受9級特大地震影響徘六,放射性物質(zhì)發(fā)生泄漏榴都。R本人自食惡果不足惜待锈,卻給世界環(huán)境...
    茶點故事閱讀 41,168評論 3 328
  • 文/蒙蒙 一竿音、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧春瞬,春花似錦、人聲如沸随常。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,783評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽涝影。三九已至,卻和暖如春序目,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背伯襟。 一陣腳步聲響...
    開封第一講書人閱讀 32,918評論 1 269
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點兒被人妖公主榨干…… 1. 我叫王不留嘿辟,地道東北人片效。 一個月前我還...
    沈念sama閱讀 47,962評論 2 370
  • 正文 我出身青樓,卻偏偏與公主長得像淀衣,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子蛮浑,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 44,781評論 2 354

推薦閱讀更多精彩內(nèi)容