NSScreencast Episode #140 UIAttachments
buttonを押すとbuttonが漂って、その後落ちるアニメーション
- buttonTapped
- animator = UIDynamicAnimator(referenceView: self.view)
- gravity = UIGravityBehavior(items: [button, label])
- var collision = UICollisionBehavior(items: [button, label])
- buttonAttachment = UIAttachmentBehavior
- attachedToItem
- offsetFromCenter
- buttonAttachment?.damping = CGFloat.max
- var anchor = UIAttachmentBehavior
- attachedToAnchor
- delay(2.0) {
- self.animator?.removeBehavior(self.buttonAttachment)
- self.delay(0.5) {
- self.animator?.removeBehavior(anchor)
- self.animator?.removeBehavior(collision)
- func delay(seconds: Double, block: () -> ()) {
- dispatch_after(time, dispatch_get_main_queue(), block)