Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
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
480
自社コンテンツ配信 のためのWebView Tips
gentlesoft
2
5.7k
実践Protocol-Extension
gentlesoft
0
86
iOS9のUIKitDynamics
gentlesoft
0
53
SwiftでUIKitDynamics
gentlesoft
0
60
CoreDataによるデータ駆動型プログラミング
gentlesoft
0
200
Other Decks in Programming
See All in Programming
Kiroで創り、AgentCoreで繋ぐ!AWSで実践する「AI-DLC」から「AIエージェント統合」までの最新地図
licux
3
500
市販E-Readerを乗っ取れ 〜Embedded Swiftで電子ペーパーガジェットを制御する〜
trickart
0
160
DroidKaigi 2026 「個人開発という実験場: Android エンジニアが手にする4つの自由」
slashnephy
0
230
RSSとCodexを使ってX投稿自動化してみた
ochtum
0
110
マイコン向けの軽量Ruby「PicoRuby」で各種デバイスを制御するネイティブアプリの実現手法
bash0c7
0
320
モバイル交通系ICへのチャージ実例から考える、クロスプラットフォーム開発におけるiOS実機テスト設計とCI運用
yusuga
1
280
コンパウンドプロダクト開発のためのローカルプロセスマネージャー再発明 #layerxgo
izumin5210
0
660
AWS DevOps Agentで インシデント対応をAIに任せたい
honmarkhunt
7
2.7k
LLMは4年分のCompose移行を再現できるのか?実プロダクト279件のXMLで探る自動化の境界線
makun
0
520
Hello, Hiroshima Geospatial Data! — Exploring DoboX with Python
ra0kley
0
180
フロントエンドUIフレームワークのこれまでとこれから
ssssota
4
2.1k
自分的「カンファレンスの楽しみ方」
syumai
0
200
Featured
See All Featured
Music & Morning Musume
bryan
47
7.4k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
820
Design in an AI World
tapps
1
310
Making Projects Easy
brettharned
120
6.7k
RailsConf 2023
tenderlove
30
1.5k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
570
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
600
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
890
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
520
The untapped power of vector embeddings
frankvandijk
2
1.9k
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Λ׆༻ͯ͠ ΠϯλϥΫςΟϒͰ ΞχϝʔγϣϯϦονͳ ΞϓϦΛ࣮͠Α͏ʂ