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
IdentifiableUIKit
Search
gaussbeam
November 25, 2016
Technology
1
420
IdentifiableUIKit
2016.11.25 shinagawa.swift
gaussbeam
November 25, 2016
Tweet
Share
More Decks by gaussbeam
See All by gaussbeam
CI/CDと継続的ワークフロー改善
gaussbeam
2
2.1k
(UI)Switch は つくれる
gaussbeam
1
640
Human Interface Guidelinesから滲み出る限界感を考える
gaussbeam
5
3.7k
ローカライズの苦しみに立ち向かう
gaussbeam
1
600
Storyboardを積極的に使うべきか?その役割に基づく一考察
gaussbeam
1
1.9k
Other Decks in Technology
See All in Technology
いまさらのStorybook
ikumatadokoro
0
110
初心者に Vue.js を 教えるには
tsukuha
5
390
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
5
49k
グローバル展開を見据えたサービスにおける機械翻訳プラクティス / dp-ai-translating
cyberagentdevelopers
PRO
1
150
コンテンツを支える 若手ゲームクリエイターの アートディレクションの事例紹介 / cagamefi-game
cyberagentdevelopers
PRO
1
130
物価高なラスベガスでの過ごし方
zakky
0
380
Datachain会社紹介資料(2024年11月) / Company Deck
datachain
3
16k
「最高のチューニング」をしないために / hack@delta 24.10
fujiwara3
21
3.4k
Vueで Webコンポーネントを作って Reactで使う / 20241030-cloudsign-vuefes_after_night
bengo4com
4
2.5k
2024-10-30-reInventStandby_StudyGroup_Intro
shinichirokawano
1
630
現地でMeet Upをやる場合の注意点〜反省点を添えて〜
shotashiratori
0
520
Aurora_BlueGreenDeploymentsやってみた
tsukasa_ishimaru
1
120
Featured
See All Featured
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
504
140k
It's Worth the Effort
3n
183
27k
Embracing the Ebb and Flow
colly
84
4.4k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
32
1.8k
10 Git Anti Patterns You Should be Aware of
lemiorhan
654
59k
Building Adaptive Systems
keathley
38
2.2k
Thoughts on Productivity
jonyablonski
67
4.3k
Bash Introduction
62gerente
608
210k
How To Stay Up To Date on Web Technology
chriscoyier
788
250k
YesSQL, Process and Tooling at Scale
rocio
167
14k
The Language of Interfaces
destraynor
154
24k
Rails Girls Zürich Keynote
gr2m
93
13k
Transcript
IdentifiableUIKit hanyu 2016.11.25 shinagawa.swift #1
Interface Builderʹͬͱؤுͬͯ΄͍͜͠ͱ ͦͷ̍ ɹؙ֯ʹ͍ͨ͠ ɹυϩοϓγϟυ͚͍ͭͨ ɹϘʔμʔ͚͍ͭͨ WJFXMBZFSDPSOFS3BEJVT WJFXMBZFSCPSEFS8JEUI WJFXMBZFSCPSEFS$PMPS 6*$PMPSXIJUF$PMPS
$($PMPS WJFXMBZFSTIBEPX0QBDJUZ WJFXMBZFSTIBEPX0⒎TFU $(4J[F XJEUI IFJHIU WJFXMBZFSTIBEPX$PMPS 6*$PMPSCMBDL$PMPS $($PMPS WJFXMBZFSTIBEPX3BEJVT TIBEPX3BEJVT
Interface Builderʹͬͱؤுͬͯ΄͍͜͠ͱ ͦͷ̎ ɹഎܠ৭ΞϓϦͷςʔϚΧϥʔͰ 0, ɹ͜͜ΞϓϦͷςʔϚΧϥʔͰ ɹ͜͜ΞϓϦͷςʔϚΧϥʔͰ … 0, ʜ
ɹ͝ΊΜɺςʔϚΧϥʔมߋʹͳͬͨ
IdentifiableUIKit •ϏϡʔͷελΠϧΛIDͰࢦఆ •Interface Builder্(=Ϗϧυෆཁ)Ͱଈ࣌ө •ελΠϧࣗ༝ʹఆٛͰ͖Δ
DEMO
@IBDesignable class IdentifiableView: UIView { @IBInspectable var … ɹoverride drawRect(rect:
CGRect) { ɹɹ… ɹ} } Interface Builder্Ͱଈ࣌ө →@IBDesignable, @IBInspectableͰ࣮ݱ
@IBDesignable class IdentifiableView: UIView { @IBInspectable var backgroundColorKey: String =
“" ɹ… ɹoverride drawRect(rect: CGRect) { ɹɹview.backgroundColor = colorStyle.getColor(colorKey: self.backgroundColorKey) ɹɹ… ɹ} } Interface Builder্Ͱଈ࣌ө + ϏϡʔͷελΠϧΛIDͰࢦఆ →drawRect()Ͱͷ৭ελΠϧऔಘΛIDʹΑΓߦ͏
protocol ColorIdentifiable { var colorStyle: ColorStyleType.Type? { get } }
protocol ColorStyleType { static var colorDic: [String: UIColor] { get } } @IBDesignable class IdentifiableView: UIView, ColorIdentifiable { … } ϏϡʔͷελΠϧΛIDͰࢦఆ →Ϗϡʔʹ(ColorStyleTypeͷมΛ௨ͯ͡)ελΠϧͷࣙॻΛ࣋ͨͤΔ
class MyColorStyle: NSObject, ColorStyleType { static var colorDic: [String: UIColor]
= [ “C01": UIColor.redColor(), … ] } ελΠϧࣗ༝ʹఆٛͰ͖Δ →IdentifiableViewΛܧঝͨ͠Ϗϡʔʹඥ͚ class MyView: IdentifiableView { override var colorStyle: ColorStyleType.Type? { return MyColorStyle.self } } →ColorStyleTypeʹద߹ͨ͠ClassΛఆٛ͠
!*#%FTJHOBCMF*EFOUJpBCMF7JFX .Z7JFX .Z$PMPS4UZMF $PMPS4UZMF5ZQF !*#*OTQFDUBCMFCBDLHSPVOE$PMPS,FZ 1: αϒΫϥεΛఆٛ 2: Interface BuilderͰIDΛࢦఆ
֓೦ਤ ݉ ͍ํ .Z7JFX4UZMF 7JFX4UZMF5ZQF
IdentifiableUIKit •ϏϡʔͷελΠϧΛIDͰࢦఆ •Interface Builder্(=Ϗϧυෆཁ) Ͱଈ࣌ө •ελΠϧࣗ༝ʹఆٛͰ͖Δ Sorry, it’s for Swift
2.2… • (view.layerͰখࡉ͍ͯ͠ΔͨΊɺෳࡶͳϏϡʔͰॏ͘ͳΔ͔…) https://github.com/gaussbeam/IdentifiableUIKit