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
650
Human Interface Guidelinesから滲み出る限界感を考える
gaussbeam
5
3.8k
ローカライズの苦しみに立ち向かう
gaussbeam
1
610
Storyboardを積極的に使うべきか?その役割に基づく一考察
gaussbeam
1
1.9k
Other Decks in Technology
See All in Technology
AGIについてChatGPTに聞いてみた
blueb
0
130
Amazon CloudWatch Network Monitor のススメ
yuki_ink
1
210
Engineer Career Talk
lycorp_recruit_jp
0
170
Shopifyアプリ開発における Shopifyの機能活用
sonatard
4
250
TanStack Routerに移行するのかい しないのかい、どっちなんだい! / Are you going to migrate to TanStack Router or not? Which one is it?
kaminashi
0
590
AWS Media Services 最新サービスアップデート 2024
eijikominami
0
200
100 名超が参加した日経グループ横断の競技型 AWS 学習イベント「Nikkei Group AWS GameDay」の紹介/mediajaws202411
nikkei_engineer_recruiting
1
170
オープンソースAIとは何か? --「オープンソースAIの定義 v1.0」詳細解説
shujisado
9
970
強いチームと開発生産性
onk
PRO
34
11k
社内で最大の技術的負債のリファクタリングに取り組んだお話し
kidooonn
1
550
RubyのWebアプリケーションを50倍速くする方法 / How to Make a Ruby Web Application 50 Times Faster
hogelog
3
940
10XにおけるData Contractの導入について: Data Contract事例共有会
10xinc
6
640
Featured
See All Featured
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
720
RailsConf 2023
tenderlove
29
900
Writing Fast Ruby
sferik
627
61k
A Tale of Four Properties
chriscoyier
156
23k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
Being A Developer After 40
akosma
86
590k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
890
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
Into the Great Unknown - MozCon
thekraken
32
1.5k
Why Our Code Smells
bkeepers
PRO
334
57k
Visualization
eitanlees
145
15k
10 Git Anti Patterns You Should be Aware of
lemiorhan
654
59k
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