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
Change Storyboard to Swift
Search
coe
July 15, 2019
Technology
1
600
Change Storyboard to Swift
Change Storyboard to Swift.
coe
July 15, 2019
Tweet
Share
More Decks by coe
See All by coe
すべてのヘルスケアデータを紐解く.pdf
coe
0
2.2k
About HealthKit nutrition
coe
0
350
Kotlin Dynamic type
coe
0
300
iOSDC 2023 Web in tvOS and watchOS
coe
1
560
iOSDC 2023 Push To Talk
coe
1
1.7k
iOSDC手で触れずにアプリを動かす技術
coe
1
1.5k
iOSDC令和時代のXML処理を考える
coe
3
2.2k
iOSDC 2021 Restore
coe
6
1.9k
詳解Storyboard
coe
7
3.5k
Other Decks in Technology
See All in Technology
組織に自動テストを書く文化を根付かせる戦略(2024冬版) / Building Automated Test Culture 2024 Winter Edition
twada
PRO
13
3.6k
権威ドキュメントで振り返る2024 #年忘れセキュリティ2024
hirotomotaguchi
2
740
継続的にアウトカムを生み出し ビジネスにつなげる、 戦略と運営に対するタイミーのQUEST(探求)
zigorou
0
520
社外コミュニティで学び社内に活かす共に学ぶプロジェクトの実践/backlogworld2024
nishiuma
0
260
開発生産性向上! 育成を「改善」と捉えるエンジニア育成戦略
shoota
1
300
複雑性の高いオブジェクト編集に向き合う: プラガブルなReactフォーム設計
righttouch
PRO
0
110
成果を出しながら成長する、アウトプット駆動のキャッチアップ術 / Output-driven catch-up techniques to grow while producing results
aiandrox
0
250
第3回Snowflake女子会_LT登壇資料(合成データ)_Taro_CCCMK
tarotaro0129
0
180
プロダクト開発を加速させるためのQA文化の築き方 / How to build QA culture to accelerate product development
mii3king
1
260
KnowledgeBaseDocuments APIでベクトルインデックス管理を自動化する
iidaxs
1
260
kargoの魅力について伝える
magisystem0408
0
200
スタートアップで取り組んでいるAzureとMicrosoft 365のセキュリティ対策/How to Improve Azure and Microsoft 365 Security at Startup
yuj1osm
0
210
Featured
See All Featured
Documentation Writing (for coders)
carmenintech
66
4.5k
BBQ
matthewcrist
85
9.4k
Speed Design
sergeychernyshev
25
670
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.1k
We Have a Design System, Now What?
morganepeng
51
7.3k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Gamification - CAS2011
davidbonilla
80
5.1k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
2
170
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.9k
VelocityConf: Rendering Performance Case Studies
addyosmani
326
24k
Transcript
4UPSZCPBSE͕ ίʔυͰॻ͘ͱ͜͏ͳΔ גࣜձࣾ"NB[JBڧ
ࣗݾհ w ڧʢ5TVZPTIJ)ZVHBʣ w J1IPOF04ʙ w "OESPJE%POVUʙ w UW04ʙ
None
4UPSZCPBSEͰ͢
͚ͲɺίʔυͰ͔ॻ͔ͳ͍ͱ ͍͚ͳ͍࣌ͬͯ͋Γ·͢ΑͶ
ίʔυͰॻ͘
class TmpViewController: UIViewController { let label = UILabel() let button
= UIButton() override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .white label.text = "Hello World" button.setTitle("button", for: .normal) view.addSubview(label) view.addSubview(button) } }
͜ͷॻ͖ํͩͱɺ 4UPSZCPBSEͰग़དྷͨ ͍ํ͕Ͱ͖ͳ͍
ྫɿҬΛλοϓͯ͠ ใΛදࣔ͢Δ ຊਤΞϓϦͷ߹
/BWJHBUJPO
.PEBM ด͡ΔϘλϯ͕ඞཁʂ
'PSN4IFFU ਖ਼ํܗͳͷͰɺ ԭೄΛผʹͨ͠ σβΠϯʹ͍ͨ͠ʂ
UW04 Ϙλϯʹ57$BQUJPO#VUUPO7JFXΛ͍͍ͨʂ
4UPSZCPBSEͷ߹ w ͜ΕΒશͯͷ7JFXʹରͯ͠ಉ Ұͷ7JFX$POUSPMMFSΛׂΓ ͯΔ͜ͱͰɺ7JFX$POUSPMMFS ॲཧ͚ͩʹઐ೦͢Δ͜ͱ͕ Ͱ͖Δ
͜Ε͕ࠔΔΑίʔυϕʔε w 7JFX$POUSPMMFSʹ7JFXͷσβΠϯΛ͍ͯ͠Δ w ʮσβΠϯ͕ҧ͏͚ͩͰɺΔ͜ͱಉ͡ʯͳ 7JFX$POUSPMMFSΛԿݸ༻ҙͨ͠Γɺϝϯςφϯε͠ ͍͔ͯͳ͍ͱ͍͚ͳ͍ w ͍ͨΜ
4UPSZCPBSEͱಉ༷ͷ͜ͱ͕ Ͱ͖Δ 7JFX$POUSPMMFSΛ࡞Δ
7JFX'BDUPSZύλʔϯ ʢԾশʣ
protocol CodeViewFactoryOwner: class { var titleLabel: UILabel! { get set
} var captionLabel: UILabel! { get set } var imageView: UIImageView! { get set } } class CodeViewFactory: CodeViewFactoryType { func create(owner:CodeViewFactoryOwner) -> UIView { return MyCodeView(owner: owner, frame: .zero) } } class MyCodeView: UIView { init(owner:CodeViewFactoryOwner, frame: CGRect) { super.init(frame: frame) self.backgroundColor = .white let imageView = UIImageView() let titleLabel = UILabel() let captionLabel = UILabel() let button = UIButton(type: .system) button.setTitle("Play", for: .normal) button.addTarget(owner, action: Selector(("clickPlay:")), for: .touchUpInside) self.addSubview(imageView) self.addSubview(titleLabel) self.addSubview(captionLabel) self.addSubview(button) owner.imageView = imageView owner.captionLabel = captionLabel owner.titleLabel = titleLabel } required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) } }
7JFX'BDUPSZύλʔϯ w ֤छ6*ύʔπΛ࣋ͬͨ0XOFSϓϩτίϧΛ࡞͢Δ w 7JFX'BDUPSZ0XOFSϓϩτίϧΛड͚औΓɺ7JFXͷ࡞ Λߦ͏ w 0XOFSʹ֤छ6*ύʔπΛ͢ w #VUUPOͳͲͷBEE5BSHFUઌʹ0XOFSΛ͢
w μʔΫϞʔυ4J[FDMBTTFTʹରԠ͢Δ߹ɺదͳ6*7JFX ܧঝΫϥεΛ࡞ΓɺUSBJU$PMMFDUJPO%JE$IBOHFͰௐ
class CodeViewController: UIViewController,CodeViewFactoryOwner { @IBOutlet weak var titleLabel: UILabel! @IBOutlet
weak var captionLabel: UILabel! @IBOutlet weak var imageView: UIImageView! private let viewFactory:CodeViewFactoryType? init(viewFactory:CodeViewFactoryType) { self.viewFactory = viewFactory super.init(nibName: nil, bundle: nil) } required init?(coder aDecoder: NSCoder) { viewFactory = nil super.init(coder: aDecoder) } override func loadView() { if let viewFactory = viewFactory { view = viewFactory.create(owner: self) } else { super.loadView() } } @IBAction func clickPlay(_ sender: Any) { } }
7JFX'BDUPSZύλʔϯ 7JFX$POUSPMMFSฤ w 7JFX$POUSPMMFSΛ0XOFSϓϩτίϧʹద߹ͤ͞Δ w 7JFX$POUSPMMFSͰૢ࡞͍ͨ͠7JFXΛXFBLWBSͰϓϩύςΟఆٛ w ͔ͤͬ͘ͳͷͰɺ!*#0VUMFU͚ͭΔ w 7JFX͔Βड͚औΔΞΫγϣϯΛGVODఆٛ
w ͔ͤͬ͘ͳͷͰɺ!*#"DUJPO͚ͭΔ w JOJU࣌ʹҙͷ7JFX'BDUPSZΛड͚औΔ w MPBE7JFX ͰɺTFMGWJFXʹ7JFX'BDUPSZ͔Β࡞ͬͨ7JFXΛׂΓͯΔ
7JFX'BDUPSZύλʔϯ ϝϦοτ w 7JFX$POUSPMMFS͕7JFXͷίʔυͰΒ·ͳ͍ w ذͱ͔JT)JEEFOͱ͔࡞Βͳ͍͍ͯ͘ w 7JFX$POUSPMMFSΛ৭ʑͳγʔϯͰ͍·ΘͤΔ w 7JFX$POUSPMMFS͕ɺͲ͏͍͏7JFXσβΠϯʹͳ͍ͬͯΔ͔ؾʹ͠ͳͯ͘
͍͍ w 6*#VUUPOͩΖ͏ͱɺ57$BQUJPO#VUUPO7JFXͩΖ͏ͱɺΠϯλϥΫ γϣϯΛॲཧ͢Δ͚ͩ w ίʔυϕʔεͱ9JCϕʔεͱ4UPSZCPBSEϕʔεΛ؆୯ʹΓସ͑ΒΕΔ
9JCͷ߹ͷ7JFX'BDUPSZྫ class XibViewFactory: CodeViewFactoryType { func create(owner:CodeViewFactoryOwner) -> UIView {
let nib = UINib(nibName: "CodeXibView", bundle: nil) let xibview = nib.instantiate(withOwner: owner, options: nil) return xibview.first as! UIView } } ˞YJCϑΝΠϧͷ'JMF`TPXOFSͷ$MBTTʹ7JFX$POUSPMMFSΛׂΓ͓ͯͯ͘͜ ͱ
4UPSZCPBSEͷ߹ override func loadView() { if let viewFactory = viewFactory
{ view = viewFactory.create(owner: self) } else { super.loadView()// ←͜͜ } } 4UPSZCPBSEͷ߹ɺWJFX'BDUPSZOJMͳͨΊɺ4UPSZCPBSEͷઃఆͰ6*͕ ߏங͞ΕΔ
·ͱΊ w 4UPSZCPBSEͱಉ͡ײ͡Ͱ7JFX7JFX$POUSPMMFSΛ࡞Γͨ ͍߹ɺ w 7JFX$POUSPMMFSͷ֎͔Β7JFXΛJOKFDU͢Δ w ΧελϜ7JFXɺMPBE7JFX ͰɺTVQFSMPBE7JFX ΛݺͣʹTFMGWJFXʹઃఆ͢Δ
w IUUQTEFWFMPQFSBQQMFDPNEPDVNFOUBUJPO VJLJUVJWJFXDPOUSPMMFSMPBEWJFX
if #available(iOS 13.0, *) { self.backgroundColor = .systemBackground } else
{ self.backgroundColor = .white } Ͱɺ͜͏͍͏04ؒͷΘͣΒΘ͠͞Λແͨ͘͢Ίʹɺ 4UPSZCPBSE༗ޮͰ͢Αɻ ʢ4UPSZCPBSE্Ͱ4ZTUFN#BDLHMPVE$PMPSΛઃఆ͢Δ͚ͩͰ શͯͷ04ʹରԠͰ͖Δʣ
גࣜձࣾ"NB[JBͰ ΤϯδχΞΛืू͍ͯ͠·͢ IUUQTBNB[JBDPKQDBSFFS