Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
UIKitDynamicsの活用法
Search
Shinji Kobayashi
March 05, 2016
Programming
620
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
UIKitDynamicsの活用法
yidev 第22回勉強会
2016年3月5日
Shinji Kobayashi
March 05, 2016
More Decks by Shinji Kobayashi
See All by Shinji Kobayashi
5分でできる UITableViewのDrag & Drop
gentlesoft
0
470
自社コンテンツ配信 のためのWebView Tips
gentlesoft
2
5.6k
実践Protocol-Extension
gentlesoft
0
84
iOS9のUIKitDynamics
gentlesoft
0
50
SwiftでUIKitDynamics
gentlesoft
0
59
CoreDataによるデータ駆動型プログラミング
gentlesoft
0
200
Other Decks in Programming
See All in Programming
Creating Composable Callables in Contemporary C++
rollbear
0
210
才能?センス?知らん、 続けたもん勝ちだ。-- 結婚・出産・癌を越えてなお、私がプロダクトを創り続ける理由
16bitidol
2
860
ローカルLLMでどこまでコードが書けるか -縮小版 / How much code can be written on a local LLM Shortened
kishida
2
190
AWS CDK を「作」ってみた 〜フルスクラッチで見えた CDK の裏側〜 / aws-cdk-from-scratch
gotok365
3
360
Snowflake Summitでの新機能 CoCo / CoWork / snowflake-summit-2026-overall-what-new-coco
tatsuhiro
1
230
ランチタイムLT会3周年!ランチタイムLT会を3年間続けられたお話
y0hgi
1
140
吝嗇家のためのAI活用 / AI development for miser - ChatGPT + Issue Driven Development
tooppoo
0
190
Apache Hive: そしてCloud Native Lakehouseへ
okumin
1
110
5分で問診!Composer セキュリティ健康診断
codmoninc
0
230
分散システム、なんですぐ死んでしまうん?耐障害性を高めたいあなたのためのレジリエンスパターン入門
mshibuya
7
6k
アルゴリズムは何を圧縮しているのか ─ Haskell から育った「圧縮代数」というメンタルモデル
naoya
16
3.5k
Claude Opus 4.6以後の受託開発エンジニアの変化(Claude Code開発ノウハウ大公開スペシャルbyクラスメソッド)
iidatakuma
1
740
Featured
See All Featured
Designing Experiences People Love
moore
143
24k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
63
55k
A Modern Web Designer's Workflow
chriscoyier
698
190k
New Earth Scene 8
popppiees
3
2.4k
Making Projects Easy
brettharned
120
6.7k
Utilizing Notion as your number one productivity tool
mfonobong
4
410
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
510
Joys of Absence: A Defence of Solitary Play
codingconduct
1
410
Facilitating Awesome Meetings
lara
57
7k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
230
Reality Check: Gamification 10 Years Later
codingconduct
0
2.2k
Transcript
UIKitDynamicsͷ׆༻๏ Shinji Kobayashi GentleSoft yidev ୈ̎̎ճษڧձ
NameɿShinji Kobayashi Twitterɿ@gentlejkov GentleSoft Who are you? http://gentlesoft.net
2DͷཧԋࢉΛͬͨΞχϝʔγϣϯ͕ ؆୯ʹ࡞Ͱ͖ΔϥΠϒϥϦ UIKitDynamicsͱ ௨ৗͷΞϓϦέʔγϣϯதʹཧԋࢉͷ ΞχϝʔγϣϯΛ؆୯ʹಋೖͰ͖Δ
2DͷཧԋࢉΛͬͨΞχϝʔγϣϯ͕ ؆୯ʹ࡞Ͱ͖ΔϥΠϒϥϦ UIKitDynamicsͱ ௨ৗͷΞϓϦέʔγϣϯதʹཧԋࢉͷ ΞχϝʔγϣϯΛ؆୯ʹಋೖͰ͖Δʁ
UIKitDynamicsͷಛ •ඪ४Ͱ༻ҙ͞Ε͍ͯΔ༰ͳΒෛՙͰ ཧԋࢉΛ࣮Ͱ͖Δ •࣮ࣗମׂͱ؆୯ •iOS8·Ͱඪ४ͷػೳ͕Γͳ͔ͬͨ ͕ɺiOS9ͰͷػೳՃʹΑΓඞཁͳཧԋ ࢉ͕ग़ἧ͖ͬͯͨ
UIKitDynamicsͷ •ཧԋࢉʹԊΘͳ͍ಈ͖Ͱ͖ͳ͍ •ࢥͬͨ௨Γʹಈ͔͢ͷ͍͠ •Կʹ͍͍͑ͷ͔͔Βͳ͍
UIKitDynamicsͷ͍ಓ •UIViewΛཧԋࢉʹԊͬͨΞχϝʔγϣϯ ͤͯ͞ɺϦονͳදݱΛ͢Δ •ը໘ભҠʹཧԋࢉͷΞχϝʔγϣϯΛऔ ΓೖΕͯ༡Ϳ
UIDynamicItemϓϩτίϧΛ࣮ͨ͠Ϋϥε UIKitDynamicsͷର •UIView •UICollectionViewLayoutAttributes UICollectionViewͷCustumLayoutΛ͏
• UIAttachmentBehaviorɹ-ɹόω • UICollisionBehaviorɹ-ɹিಥ • UIGravityBehaviorɹ-ɹॏྗ • UIDynamicItemBehaviorɹ-ɹମͷಛੑ • UIPushBehaviorɹ-ɹΤωϧΪʔ
• UISnapBehaviorɹ-ɹҠಈ UIKitDynamics(ʙiOS8)
Demo UIKitDynamics(ʙiOS8)
• UIDynamicItemCollisionBoundsType • UIFieldBehavior • linearGravityFieldWithVectorɹ-ɹॏྗۭؒ • radialGravityFieldWithPosition -Ҿྗʗి࣓ྗ •
noiseFieldWithSmoothness:animationSpeed • UIAttachmentBehavior 1. limitAttachmentWithItemɹ-ɹϩʔϓ 2. pinAttachmentWithItem - Google 13Hit 3. slidingAttachmentWithItem - Google 9Hit 4. fixedAttachmentWithItem - Google 10Hit UIKitDynamics(iOS9ʙ)
Demo
UIDynamicAnimatorͷΦϒδΣΫτΛ࡞ ࣮खॱ ඞཁͳBehaviorΛ࡞͠ɺΞχϝʔγϣϯ ͍ͤͨ͞ViewΛηοτ UIDynamicAnimatorʹBehaviorΛηοτ
࣮ʢൈਮʣ 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)
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) ఆܕจ
ٙ Animator͕ىಈͨ࣌͠Ͱແࢹ͞ΕΔ ઃఆͨ͠AutoLayoutͲ͏ͳΔʁ
ٙ ϦΞϧλΠϜʹऔΕΔɺ༏ल UIViewͷframe͔Β࠲ඪऔΕΔʁ
ٙ GestureRecognizerͬͪΓ͑Δ ΞχϝʔγϣϯதͷViewͷλονఆʁ
ٙ ແཧɺແବ UIViewͷframeʹҙͷ࠲ඪΛ ઃఆͯ͠ViewΛಈ͔ͤΔʁ
ٙ ViewΛૢ࡞͍ͨ࣌͠Ͳ͏͢Δʁ UIAttachmentBehaviorʹૢ࡞͍ͨ͠Viewͱ Ҡಈ͍ͨ͠ҐஔͷanchorPointΛࢦఆɺ lengthΛ0ʹ͢Δͱૂ͍ͷҐஔʹಈ͔ͤΔ
ٙ Ξχϝʔγϣϯ͕ऴྃͨ͠ఆʁ ͯ͢ͷΦϒδΣΫτ͕ఀࢭͨ࣌͠ɺ UIDynamicAnimatorDelegateͷ dynamicAnimatorDidPauseϝιου͕ݺΕΔ
ٙ Ξχϝʔγϣϯ͕ऴྃͨ͠Β View͕ݩͷҐஔʹͬͨΓ͢Δʁ ͠ͳ͍ AnimatorΛআͯ͠ɺViewͷҐஔͦͷ··
ٙ ͦͷ࣌ͷAutoLayoutʁ ͔Γ·ͤΜ
·ͱΊ •UIKitDynamicsUIViewͱUICollectionView Ͱ͑ͯɺͦͷ࣮ࣗମ༰қ •େͷύλʔϯͷཧԋࢉΛඪ४ػೳͰ࣮ Ͱ͖ΔΑ͏ʹͳͬͨ •ΞχϝʔγϣϯΛϦΞϧλΠϜʹิͯ͠ɺ ૢ࡞͢Δ͜ͱ͕Ͱ͖ΔͷͰɺΠϯλϥΫςΟ ϒͳΞχϝʔγϣϯʹ͍͍ͯΔ
UIKitDynamicsΛ׆༻ͯ͠ ΠϯλϥΫςΟϒͰ ΞχϝʔγϣϯϦονͳ ΞϓϦΛ࣮͠Α͏ʂ