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
610
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
AI 時代のソフトウェア設計の学び方
masuda220
PRO
29
12k
技術記事、 専門家としてのプログラマ、 言語化
mizchi
13
6k
Lessons from Spec-Driven Development
simas
PRO
0
200
スマートグラスで並列バイブコーディング
hyshu
0
140
Webフレームワークの ベンチマークについて
yusukebe
0
170
ADKを使って簡単にAIエージェントを作ってみよう
k1mu21
0
260
Oxlintのカスタムルールの現況
syumai
6
1.1k
並列実装の現場、2ヶ月間実務でAIを使い倒したAIもPCも私も限界が近い
ming_ayami
0
130
決定論的オーケストレーションの設計と実装 / Design and Implementation of Deterministic Orchestration
nrslib
4
1.4k
気圧・高度・GPSを記録&可視化するアプリ「Koudo」を作った話
hjmkth
1
260
フロントエンドとバックエンドで「1文字」を揃えよう
youkidearitai
PRO
0
690
コンテキストの使い捨てをやめる — ビジネスルール駆動開発と miko —
ioki
0
200
Featured
See All Featured
We Are The Robots
honzajavorek
0
250
For a Future-Friendly Web
brad_frost
183
10k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.3k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.5k
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
300
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.5k
Claude Code のすすめ
schroneko
67
230k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
210
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
55k
Designing Powerful Visuals for Engaging Learning
tmiket
1
410
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
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Λ׆༻ͯ͠ ΠϯλϥΫςΟϒͰ ΞχϝʔγϣϯϦονͳ ΞϓϦΛ࣮͠Α͏ʂ