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
440
IdentifiableUIKit
2016.11.25 shinagawa.swift
gaussbeam
November 25, 2016
Tweet
Share
More Decks by gaussbeam
See All by gaussbeam
成長する組織のナレッジベースのつくりかた_知識基盤のデザインとメタデザイン
gaussbeam
0
810
CI/CDと継続的ワークフロー改善
gaussbeam
2
2.2k
(UI)Switch は つくれる
gaussbeam
1
660
Human Interface Guidelinesから滲み出る限界感を考える
gaussbeam
5
3.8k
ローカライズの苦しみに立ち向かう
gaussbeam
1
620
Storyboardを積極的に使うべきか?その役割に基づく一考察
gaussbeam
1
1.9k
Other Decks in Technology
See All in Technology
Cloudflareで実現する AIエージェント ワークフロー基盤
kmd09
0
290
駆け出しリーダーとしての第一歩〜開発チームとの新しい関わり方〜 / Beginning Journey as Team Leader
kaonavi
0
120
20250116_JAWS_Osaka
takuyay0ne
2
200
Goで実践するBFP
hiroyaterui
1
120
re:Invent 2024のふりかえり
beli68
0
110
embedパッケージを深掘りする / Deep Dive into embed Package in Go
task4233
1
220
Formal Development of Operating Systems in Rust
riru
1
420
コロプラのオンボーディングを採用から語りたい
colopl
5
1.3k
FODにおけるホーム画面編成のレコメンド
watarukudo
PRO
2
280
今年一年で頑張ること / What I will do my best this year
pauli
1
220
今から、 今だからこそ始める Terraform で Azure 管理 / Managing Azure with Terraform: The Perfect Time to Start
nnstt1
0
240
DMMブックスへのTipKit導入
ttyi2
1
110
Featured
See All Featured
Building Adaptive Systems
keathley
38
2.4k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Optimising Largest Contentful Paint
csswizardry
33
3k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.8k
Designing for humans not robots
tammielis
250
25k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
120k
Unsuck your backbone
ammeep
669
57k
Thoughts on Productivity
jonyablonski
68
4.4k
Bash Introduction
62gerente
610
210k
StorybookのUI Testing Handbookを読んだ
zakiyama
28
5.4k
Building Your Own Lightsaber
phodgson
104
6.2k
4 Signs Your Business is Dying
shpigford
182
22k
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