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
390
IdentifiableUIKit
2016.11.25 shinagawa.swift
gaussbeam
November 25, 2016
Tweet
Share
More Decks by gaussbeam
See All by gaussbeam
CI/CDと継続的ワークフロー改善
gaussbeam
2
2k
(UI)Switch は つくれる
gaussbeam
1
590
Human Interface Guidelinesから滲み出る限界感を考える
gaussbeam
5
3.6k
ローカライズの苦しみに立ち向かう
gaussbeam
1
580
Storyboardを積極的に使うべきか?その役割に基づく一考察
gaussbeam
1
1.9k
Other Decks in Technology
See All in Technology
kcp: Kubernetes APIs Are All You Need #techfeed_live / TechFeed Experts Night 28th
ytaka23
1
180
AWS アーキテクチャ作図入門/aws-architecture-diagram-101
ma2shita
16
6.7k
生成AIと産業向けソフトウェアの自動生成 〜 ハノーバーメッセ2024より〜
kioto
2
420
Cloudflare WorkersがPythonに対応したので試してみた
miura55
0
190
TanStack Routerで型安全かつ効率的なルーティングを実現
ytaisei
4
760
株式会社EventHub・エンジニア採用資料
eventhub
0
2.1k
「できる!」を増やすGitHub Copilot活用法 / How to use GitHub Copilot to expand your possibilities
sansan_randd
1
220
Oracle Cloud Infrastructureデータベース・クラウド:各バージョンのサポート期間
oracle4engineer
PRO
12
7.9k
エムスリーQAチーム紹介資料 / Introduction of M3 QA Team
m3_engineering
1
280
Zero Data Loss Autonomous Recovery Service サービス概要
oracle4engineer
PRO
0
2k
Databricksの生成AI戦略
taka_aki
1
350
AWSの生成AI入門書を執筆しました🎉
minorun365
PRO
0
130
Featured
See All Featured
How GitHub (no longer) Works
holman
305
140k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
126
32k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
188
16k
Navigating Team Friction
lara
179
13k
GitHub's CSS Performance
jonrohan
1025
450k
Optimising Largest Contentful Paint
csswizardry
13
2.4k
The Invisible Side of Design
smashingmag
294
49k
How to name files
jennybc
65
93k
Reflections from 52 weeks, 52 projects
jeffersonlam
345
19k
BBQ
matthewcrist
80
8.8k
Producing Creativity
orderedlist
PRO
338
39k
The Illustrated Children's Guide to Kubernetes
chrisshort
32
47k
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