Upgrade to Pro — share decks privately, control downloads, hide ads and more …

UIKitDynamicsの活用法

 UIKitDynamicsの活用法

yidev 第22回勉強会
2016年3月5日

Shinji Kobayashi

March 05, 2016
Tweet

More Decks by Shinji Kobayashi

Other Decks in Programming

Transcript

  1. • UIDynamicItemCollisionBoundsType • UIFieldBehavior • linearGravityFieldWithVectorɹ-ɹॏྗۭؒ • radialGravityFieldWithPosition -Ҿྗʗి࣓ྗ •

    noiseFieldWithSmoothness:animationSpeed • UIAttachmentBehavior 1. limitAttachmentWithItemɹ-ɹϩʔϓ 2. pinAttachmentWithItem - Google 13Hit 3. slidingAttachmentWithItem - Google 9Hit 4. fixedAttachmentWithItem - Google 10Hit UIKitDynamics(iOS9ʙ)
  2. ࣮૷ʢൈਮʣ animator = UIDynamicAnimator(referenceView: source) let gravity = UIGravityBehavior(items: [destination])

    gravity.magnitude = 12 let collision = UICollisionBehavior(items: [destination]) collision.addBoundaryWithIdentifier("bottom", fromPoint: CGPoint(x: 0, y: source.bounds.height), toPoint: CGPoint(x: source.bounds.width, y: source.bounds.height)) let item = UIDynamicItemBehavior(items: [destination]) item.elasticity = 0.5 item.resistance = 0.8 animator.delegate = self animator.addBehavior(gravity) animator.addBehavior(collision) animator.addBehavior(item)
  3. CollectionViewLayoutΛܧঝͯ͠CustomLayoutΛ࡞੒ ࣮૷खॱ(UICollectionView) override func layoutAttributesForItemAtIndexPath(indexPath: NSIndexPath) -> UICollectionViewLayoutAttributes! { return

    animator.layoutAttributesForCellAtIndexPath(indexPath) } override func layoutAttributesForElementsInRect(rect: CGRect) -> [AnyObject]? { return animator.itemsInRect(rect) } animator = UIDynamicAnimator(collectionViewLayout: self) ఆܕจ