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
UIライブラリは どう設計されるべきか
Search
kazuhiro4949
October 13, 2017
Technology
3
3k
UIライブラリは どう設計されるべきか
iOSDC 2017 Reject Conference Days 1
https://iosdc-reject-conference.connpass.com/event/64175/
kazuhiro4949
October 13, 2017
Tweet
Share
More Decks by kazuhiro4949
See All by kazuhiro4949
SwiftUIをUIKitのライフサイクルで拡張するTips
kazuhiro4949
4
2.5k
iOS15でプッシュ通知のテストが大変だった話
kazuhiro4949
0
560
Source Editor Extensionと SwiftSyntaxでコード自動生成ツール を作る
kazuhiro4949
2
3.6k
iOS 12サポート終了で使えるAPIおさらい
kazuhiro4949
2
320
Source Editor ExtensionとSwiftSyntaxでコード自動生成
kazuhiro4949
0
70
大企業の最前線でコードを書き続けるためにやってきたこと
kazuhiro4949
28
19k
10分で振り返るここ数年のWWDCの技術トレンド
kazuhiro4949
0
270
コードを書きながら同時に設計していくためのiOSアプリ開発方針
kazuhiro4949
6
2.5k
身近な技術的課題から始めるOSSプロジェクト
kazuhiro4949
0
260
Other Decks in Technology
See All in Technology
Adopting Jetpack Compose in Your Existing Project - GDG DevFest Bangkok 2024
akexorcist
0
100
信頼性に挑む中で拡張できる・得られる1人のスキルセットとは?
ken5scal
2
530
OCI 運用監視サービス 概要
oracle4engineer
PRO
0
4.8k
10XにおけるData Contractの導入について: Data Contract事例共有会
10xinc
5
610
Amplify Gen2 Deep Dive / バックエンドの型をいかにしてフロントエンドへ伝えるか #TSKaigi #TSKaigiKansai #AWSAmplifyJP
tacck
PRO
0
370
誰も全体を知らない ~ ロールの垣根を超えて引き上げる開発生産性 / Boosting Development Productivity Across Roles
kakehashi
1
220
EventHub Startup CTO of the year 2024 ピッチ資料
eventhub
0
110
DMARC 対応の話 - MIXI CTO オフィスアワー #04
bbqallstars
1
160
ISUCONに強くなるかもしれない日々の過ごしかた/Findy ISUCON 2024-11-14
fujiwara3
8
870
IBC 2024 動画技術関連レポート / IBC 2024 Report
cyberagentdevelopers
PRO
0
110
障害対応指揮の意思決定と情報共有における価値観 / Waroom Meetup #2
arthur1
5
470
RubyのWebアプリケーションを50倍速くする方法 / How to Make a Ruby Web Application 50 Times Faster
hogelog
3
940
Featured
See All Featured
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.2k
YesSQL, Process and Tooling at Scale
rocio
169
14k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
0
89
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
KATA
mclloyd
29
14k
4 Signs Your Business is Dying
shpigford
180
21k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
Music & Morning Musume
bryan
46
6.2k
Art, The Web, and Tiny UX
lynnandtonic
297
20k
A Tale of Four Properties
chriscoyier
156
23k
Transcript
6*ϥΠϒϥϦ Ͳ͏ઃܭ͞ΕΔ͖͔ ,B[VIJSP)":"4)* J04%$3FKFDU$POGFSFODF%BZT
ࣗݾհ w ྛ߂ w 5XJUUFSɿLB[VIJSP w HJUIVCɿLB[VIJSP w RJJUBɿLB[VIJSP w
:BIPP+BQBO$PSQ w J04ΞϓϦΤϯδχΞ w J04ΞϓϦࠇଳ
ΞδΣϯμ w 6*ϥΠϒϥϦΛར༻ͯ͠։ൃ͢ΔதͰ໘ͨ͠ɺΫϥεͷ ࠶ར༻ੑʹର͢Δ՝ͷհ w ৽نʹ։ൃͨ͠ϥΠϒϥϦͰͲͷΑ͏ʹ՝Λղܾ͔ͨ͠ ղઆ w 6*ͷڞ௨ΫϥεΛઃܭ͢ΔࡍͷϙΠϯτΛཧ
J04ΞϓϦͷ6*ϥΠϒϥϦ w ͜͜Ͱɺ6*,JUͷΫϥεΛܧ ঝͨ͠ܗͰఏڙ͞ΕΔɺ࠶ར༻ ՄೳͳΫϥεΛѻ͏ w $PSF"OJNBUJPO $PSF(SBQIJDT $PSF5FYUͳͲ
ͷϨΠϠϑϨʔϜϫʔΫ ϑΥʔΧε͔Β֎͢ IUUQTEFWFMPQFSBQQMFDPNMJCSBSZDPOUFOUEPDVNFOUBUJPO$PDPB$PODFQUVBM$PSF"OJNBUJPO@HVJEF*OUSPEVDUJPO*OUSPEVDUJPOIUNM
͋ΔϓϩμΫτͷ
͋ΔϓϩμΫτͰϖʔδϯά6* ͷϥΠϒϥϦΛͬͯ։ൃ w 4NBSU/FXTNFSDBSJɺ :BIPPχϡʔεͰ࠾༻͞Εͯ ͍ΔΑ͏ͳɺϖʔδϯάͱԣε ΫϩʔϧϝχϡʔͷΈ߹Θͤ
ͦͷϥΠϒϥϦͰɺUJUMF͕ઃఆ͞Εͨ7$Λ"SSBZͰ ͢ͱɺܾ·ͬͨσβΠϯͷϖʔδϯά6*͕࡞ΒΕΔ ˞Πϝʔδ ࣮ࡍʹؔΘͬͨϓϩμΫτͱҧ͍·͢ let ary: [UIViewController] = [ {
$0.title = "Page1" return $0 }(UIViewController()), { $0.title = "Page2” return $0 }(UIViewController()), { $0.title = "Page3" return $0 }(UIViewController()) ] pagingViewController.childViewControllers = ary
ͦͷϥΠϒϥϦͰɺUJUMF͕ઃఆ͞Εͨ7$Λ"SSBZͰ ͢ͱɺܾ·ͬͨσβΠϯͷϖʔδϯά6*͕࡞ΒΕΔ ˞Πϝʔδ ࣮ࡍʹؔΘͬͨϓϩμΫτͱҧ͍·͢ let ary: [UIViewController] = [ {
$0.title = "Page1" return $0 }(UIViewController()), { $0.title = "Page2” return $0 }(UIViewController()), { $0.title = "Page3" return $0 }(UIViewController()) ] pagingViewController.childViewControllers = ary ϝχϡʔ͕͋Δ
ͦͷϥΠϒϥϦͰɺUJUMF͕ઃఆ͞Εͨ7$Λ"SSBZͰ ͢ͱɺܾ·ͬͨσβΠϯͷϖʔδϯά6*͕࡞ΒΕΔ ˞Πϝʔδ ࣮ࡍʹؔΘͬͨϓϩμΫτͱҧ͍·͢ let ary: [UIViewController] = [ {
$0.title = "Page1" return $0 }(UIViewController()), { $0.title = "Page2” return $0 }(UIViewController()), { $0.title = "Page3" return $0 }(UIViewController()) ] pagingViewController.childViewControllers = ary ϖʔδϯάՄೳͳ ίϯςϯπྖҬ͕͋Δ
ελΠϧύϥϝʔλͰ͢͜ͱ͕Մೳ ˞Πϝʔδ ࣮ࡍʹؔΘͬͨϓϩμΫτͱҧ͍·͢
ॳظͷγϯϓϧͳཁ݅Λຬ͍ͨͯͨ͠ w ϖʔδϯάͰ͖Δίϯςϯπ w εΫϩʔϧ͞ΕΔϝχϡʔ w ϝχϡʔʹλΠτϧ͕දࣔ͞Ε͍ͯ Δ w ݱࡏͷϖʔδҐஔͷϝχϡʔ͕ڧௐ͞
Εͯɺݱࡏ͕Θ͔ΔΑ͏ʹͳ͍ͬͯ Δ ˞Πϝʔδ ࣮ࡍʹؔΘͬͨϓϩμΫτͱҧ͍·͢
͔͠͠ཁ͕݅গͣͭ͠ෳࡶԽ͍͖ͯ͠ɺ ࠾༻ͨ͠ϥΠϒϥϦͰରԠ͖͠Εͳ͘ͳΔ
ϓϩμΫτͷʹͬͯ6*͕ࡉԽ͞Εɺ ͜͏͍ͬͨ͜ͱΛٻΊΒΕΔΑ͏ʹͳ͖ͬͯͨ w ྫ͑ w ͋Δը໘Ͱϝχϡʔͷಛ ఆͷཁૉͷ্ʹαϒλΠτ ϧΛ͚͍ͨ w ͋Δը໘Ͱίϯςϯπͱ
ϝχϡʔͷྖҬؒϘλϯ Λฒ͍ͨ ˞Πϝʔδ ࣮ࡍʹؔΘͬͨϓϩμΫτͱҧ͍·͢
ϓϩμΫτͷʹͬͯ6*͕ࡉԽ͞Εɺ ͜͏͍ͬͨ͜ͱΛٻΊΒΕΔΑ͏ʹͳ͖ͬͯͨ w ྫ͑ w ͋Δը໘Ͱϝχϡʔͷಛ ఆͷཁૉͷ্ʹαϒλΠτ ϧΛ͚͍ͨ w ͋Δը໘Ͱίϯςϯπͱ
ϝχϡʔͷྖҬؒϘλϯ Λฒ͍ͨ ˞Πϝʔδ ࣮ࡍʹؔΘͬͨϓϩμΫτͱҧ͍·͢
ར༻͍ͯͨ͠ϥΠϒϥϦͰ ཁ݅Λຬͨͤͳ͘ͳͬͯ͘Δ
৭ΜͳέʔεͰڞ௨ͰΘΕΔ6* ͲͷΑ͏ʹ࡞ΒΕΔ͖ͩΖ͏͔
͜ͷͭΛߟྀͯ͠ઃܭ͞Ε Δͱྑ͍ͷͰͳ͍͔ͱࢥ͏ ΠϯλϥΫγϣϯͷΈΛͱͯ࣋ͭ͠Ϋϥεʹ͢Δ ϨΠΞτมߋʹରͯ͠ग़དྷΔݶΓࣗ༝͕ߴ͍ঢ়ଶʹ ͢Δ ෦ίϯϙʔωϯτͷબɾஔࣗ༝Ͱ͋Δඞཁ͕͋Δ
BEE4VCWJFX @ BEE$IJME7JFX$POUSPMMFS @ ʹΑΔί ϯϙδγϣϯͰར༻Ͱ͖ΔΑ͏ʹ͢Δ
Ҏ্ͷߟ͑ํʹج͖ͮ ৽ن։ൃͨ͠ϥΠϒϥϦ
IUUQTHJUIVCDPNLB[VIJSP1BHJOH,JU 1BHJOH,JU
1BHJOH,JUͷಛ w ΠϯλϥΫγϣϯ෦ΛϥΠϒ ϥϦͰఏڙ w ϝχϡʔྖҬͱίϯςϯπྖҬ ͕࿈ಈͯ͠ಈ͘
1BHJOH,JUͷಛ w ϨΠΞτࣗ༝ʹܾΊΒΕΔ w ϝχϡʔͱίϯςϯπͷؒ ʹ7JFXΛڬΉ w ϝχϡʔͱίϯςϯπΛฒ ସ͑Δ
1BHJOH,JUͷಛ w தͷ7JFXίϯϙʔωϯτ ΞϓϦͰ༻ҙ͢Δ w ϝχϡʔͷσβΠϯΛม͑Δ w ϝχϡʔʹ6*-BCFMΛͭฒ ͨΓɺ6**NBHF7JFXΛஔ ͍ͨΓ͢Δ
͍ํ
w ҎԼͷ̎ͭͷ7JFX$POUSPMMFSΛ 4UPSZCPBSE্Ͱ$POUBJOFS7JFX ΛͬͯϨΠΞτ͢Δ w 1BHJOH.FOV7JFX$POUSPMMFS w 1BHJOH$POUFOU7JFX$POUSPMMFS 1BHJOH.FOV7JFX$POUSPMMFS 1BHJOH$POUFOU7JFX$POUSPMMFS
w 4FHVFͰઃఆͨ͠௨ৗͷ$IJME 7JFX$POUSPMMFSͱಉ͡Α͏ʹɺ ίʔυ্Ͱऔಘ͢Δ class ViewController: UIViewController { var menuViewController:
PagingMenuViewController! var contentViewController: PagingContentViewController! // … // ... override func prepare(for segue: UIStoryboardSegue, sender: Any?) { if let vc = segue.destination as? PagingMenuViewController { menuViewController = vc } else if let vc = segue.destination as? PagingContentViewController { contentViewController = vc } } } QSFQBSF GPSTFOEFS ͰTUPSZCPBSEͰઃఆ͠ ͨ7$ΛϓϩύςΟೖΕΔ
w ϝχϡʔͷཁૉʹ૬͢Δ7JFX ɺ1BHJOH.FOV$FMMΛܧঝ͠ ͯΞϓϦέʔγϣϯଆͰ༻ҙ͢ Δ w ΞϓϦͰͷڞ௨ͷελΠϧ ը໘ຖͷݸผͷελΠϧͰ ༻ҙ͢Δ ͜ͷதͷͦΕͧΕͷཁૉʹ
૬
w ಉ༷ʹϖʔδϯάதͷݱࡏҐஔ Λද͢Πϯδέʔλ 1BHJOH'PDVT7JFXΛܧঝͯ͠ ΞϓϦଆͰ༻ҙ͢Δ w ΞϓϦͰͷڞ௨ͷελΠϧ ը໘ຖͷݸผͷελΠϧͰ ༻ҙ͢Δ ݱࡏදࣔ͞Ε͍ͯΔҐஔΛ
ϝχϡʔ্Ͱදͨ͢ΊͷΠ ϯδέʔλ
var data: (menuTitle: String, vc: UIViewController) = [ (menuTitle: "test1",
vc: UIViewController()), (menuTitle: "test2", vc: UIViewController()), (menuTitle: "test3", vc: UIViewController()) ] w ը໘ʹද͍ࣔͤͨ͞ҙͷσʔ λΛ༻ҙ͢Δ w ϝχϡʔλΠτϧจࣈྻ ͷΈ w ίϯςϯπۭͷ7$Λ༻ҙ ͍ͯ͠Δ
w ϝχϡʔͷදࣔΛ࣮͢Δ w ༻ҙͨ͠σʔλΛ%BUB4PVSDF ܦ༝ͰɺඞཁͳλΠϛϯάͰ ฦ͢ w 5BCMF7JFX$PMMFDUJPO7JFXͱ ಉ༷ͳΈͰҎԼΛ͢ w
σʔλ w ηϧͷ෯ w σʔλΛόΠϯυͨ͠ηϧ // ϝχʔ෦ͷDataSource extension ViewController: PagingMenuViewControllerDataSource { func numberOfItemForMenuViewController( viewController: PagingMenuViewController) -> Int { return data.count } func menuViewController(viewController: PagingMenuViewController, widthForItemAt index: Int) -> CGFloat { return 100 } func menuViewController(viewController: PagingMenuViewController, cellForItemAt index: Int) -> PagingMenuViewCell { let cell = viewController.dequeueReusableCell(withReuseIdentifier: "MenuCell", for: index) as! MenuCell cell.titleLabel.text = data[index].menuTitle return cell } }
w ίϯςϯπͷදࣔΛ࣮͢Δ w ༻ҙͨ͠σʔλΛ%BUB4PVSDF ܦ༝ͰɺඞཁͳλΠϛϯάͰ ฦ͢ w 5BCMF7JFX$PMMFDUJPO7JFX ͱಉ༷ͳΈ w
σʔλ w σʔλΛόΠϯυͨ͠ 7JFX$POUSPMMFS // ίϯςϯπ෦ͷDataSource extension ViewController: PagingContentViewControllerDataSource { func numberOfItemForContentViewController( ɹ viewController: PagingContentViewController) -> Int { return data.count } func contentViewController(viewController: PagingContentViewController, viewControllerAt index: Int) -> UIViewController { return data[index].vc } }
w ৼΔ͍ͷΈΛ༷ͱͯ࣋ͭ͠ҎԼͷΫ ϥεΛίϯϙδγϣϯ͢Δ w 1BHJOH.FOV7JFX$POUSPMMFS w 1BHJOH$POUFOU7JFX$POUSPMMFS w ҎԼͷཁૉΞϓϦଆͰ༻ҙ͢Δ w
ϨΠΞτ w தʹԿΛදࣔͤ͞Δ͔
ྫ͑ͲͷΑ͏ͳཁ݅ ରԠͰ͖ΔΑ͏ʹͳ͔ͬͨ
ྫ͑ͲͷΑ͏ͳཁ݅ ରԠͰ͖ΔΑ͏ʹͳ͔ͬͨ w ϨΠΞτΛมߋͯ͠ϝχϡʔ ͱίϯςϯπͷؒʹΧςΰϦબ ϘλϯΛݻఆͯ͠ฒ͍ͨ ˞Πϝʔδ ࣮ࡍʹؔΘͬͨϓϩμΫτͱҧ͍·͢
ྫ͑ͲͷΑ͏ͳཁ݅ ରԠͰ͖ΔΑ͏ʹͳ͔ͬͨ w ϝχϡʔͷҰ෦ཁૉʹ্෦ʹ ࠓɾ໌ͱ͍ͬͨऍΛ͚ͭ ͍ͨ ˞Πϝʔδ ࣮ࡍʹؔΘͬͨϓϩμΫτͱҧ͍·͢
ྫ͑ͲͷΑ͏ͳཁ݅ ରԠͰ͖ΔΑ͏ʹͳ͔ͬͨ w ಈըͷϓϨΠϠʔ͕͋ͬͯɺͦ ͷ෦ϝχϡʔͱࣅͨΑ͏ͳ ײ͡ͷಈ͖ͷ6*Λ࡞ͬͯཉ͍͠ ˞Πϝʔδ ࣮ࡍʹؔΘͬͨϓϩμΫτͱҧ͍·͢
ҎԼͷ݅Λҙࣝ͢Δ͜ͱͰɺ࠶ར༻ੑ Λҡ࣋ͭͭ͠Ϋϥεͷڞ௨Խ͕Ͱ͖ͨ ΠϯλϥΫγϣϯͷΈΛͱͯ࣋ͭ͠Ϋϥεʹ͢Δ ϨΠΞτมߋʹରͯ͠ग़དྷΔݶΓࣗ༝͕ߴ͍ঢ়ଶʹ ͢Δ ෦ίϯϙʔωϯτͷબɾஔࣗ༝Ͱ͋Δඞཁ͕͋Δ
BEE4VCWJFX @ BEE$IJME7JFX$POUSPMMFS @ ʹΑΔί ϯϙδγϣϯͰར༻Ͱ͖ΔΑ͏ʹ͢Δ
·ͱΊ w ڞ௨ΫϥεΛ։ൃ͢Δ࣌࠶ར༻ੑͷ؍ͰΛҙࣝ͢Δɻ࣮ͷ γϯϓϧ͞ͱॊೈੑ௨ৗτϨʔυΦϑͳͷͰόϥϯεΛݟۃΊΔ w J04Ͱ6*,JUͷϨΠϠʹڞ௨ΫϥεΛߏங͢Δ߹ɺΠϯλϥΫγϣ ϯͷΈΛنఆ͢Δͷ͕ྑ͍ w ϨΠΞτɺΠϯλϥΫγϣϯͷ༷Λյ͞ͳ͍ఔͰग़དྷΔݶΓ ࣗ༝͕ߴ͍ͱྑ͍
w ෦ίϯϙʔωϯτͷஔͦͷελΠϧΞϓϦʹ·͔ͤͯؔ༩͠ ͳ͍ͷ͕ྑ͍
ࢀߟࢿྉ w 6*,JUc"QQMF%FWFMPQFS%PDVNFOUBUJPO w IUUQTEFWFMPQFSBQQMFDPNEPDVNFOUBUJPOVJLJU w $PODFQUTJO0CKFDUJWF$1SPHSBNNJOH w IUUQTEFWFMPQFSBQQMFDPNMJCSBSZDPOUFOUEPDVNFOUBUJPO(FOFSBM$PODFQUVBM $PDPB&ODZDMPQFEJB*OUSPEVDUJPO
w LB[VIJSP1BHJOH,JU w IUUQTHJUIVCDPNLB[VIJSP1BHJOH,JU w ϝϧΧϦεϚϗͰ͔ΜͨΜϑϦϚΞϓϦ w IUUQTXXXNFSDBSJDPNKQ w :BIPPχϡʔεެࣜΞϓϦ:BIPPχϡʔε w IUUQTOFXTZBIPPDPKQQSPNPBQQZKOFXT w 4NBSU/FXT w IUUQTXXXTNBSUOFXTDPNKB