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.
网友评论