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
制約を使ってViewを動かす
Search
taminif
March 12, 2017
Programming
290
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
制約を使ってViewを動かす
taminif
March 12, 2017
More Decks by taminif
See All by taminif
React Native New Architecture 移行実践報告
taminif
1
240
「とりあえずAI」が招く悲劇〜私がAIで生産性を下げるまでの話〜 / The tragedy caused by "AI for now" - The story of how I used AI to reduce my productivity
taminif
1
310
PuppeteerとPlaywrightの15日間の演劇 / relation of Puppeteer and Playwright
taminif
3
2.3k
Redashの開発はじめました / How to get started Redash development
taminif
0
810
私の生活を変えたHeadless Chrome / Headless Chrome who changed my life
taminif
3
540
WebSocketをiOSに持ち込んで辛い思いをした経験がありますか!? / have you painful experience in web socket?
taminif
3
6.2k
LINEで馬券を購入する / Purchase a betting ticket at LINE
taminif
1
1.7k
SkyWayで一年間運用してきたけどWebRTCってつらいんじゃないの
taminif
2
1k
オンライン英会話とSkyWay
taminif
0
550
Other Decks in Programming
See All in Programming
柔軟なPDFレイアウトエディタを支える型システム設計 — Discriminated UnionとConditional Typeの実践
minako__ph
4
1.4k
TypeSpec で繋ぐ複数プロダクトの型安全
maroon8021
1
380
jQueryをバージョンアップする前に使いたいjQuery Migrate
matsuo_atsushi
0
190
技術記事、AIに書かせるか、自分で書くか? 〜それでも私が自分の手で書く理由〜 / #QiitaConference
jnchito
2
1.3k
脅威をエンジニアリングの糧にして――現場編 / Turning Threats into Engineering Fuel — Field Edition
nrslib
0
250
Signal Forms: Beyond the Basics @ngBaguette 2026 in Paris
manfredsteyer
PRO
0
230
Old Dog, New Tricks: The Java 25 Reinvention - JNation
bazlur_rahman
0
140
TSKaigi Night Talks 2026_TypeScriptでサプライチェーンの整合性を型に閉じ込める
geekplus_tech
0
300
Spec Driven Development | AI Summit Lisbon
danielsogl
PRO
0
150
Spring Security 実践 ─ GraphQL APIで実務に役立つ 認証・認可 を学ぶ
wagyu
0
150
GitHub Copilot CLIのいいところ
htkym
2
1.3k
TAKTでAI駆動開発の品質を設計する
j5ik2o
6
930
Featured
See All Featured
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.9k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Darren the Foodie - Storyboard
khoart
PRO
3
3.4k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.2k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
190
So, you think you're a good person
axbom
PRO
2
2k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Bash Introduction
62gerente
615
210k
Making Projects Easy
brettharned
120
6.7k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
300
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.9k
Claude Code のすすめ
schroneko
67
230k
Transcript
੍Λͬͯ ViewΛಈ͔͢ ؔϞόΠϧΞϓϦݚڀձ #23 2017/02/28 େౡ ޫو
ࣗݾհ • ΣϒϦΦגࣜձࣾWEBΤϯδχΞ • ΞϓϦΤϯδχΞ ʢࣗশʣ • ࣙॻαʔϏεͷձࣾʹۈΊͯ·͕͢ӳޠͰ͖·ͤΜ • Try!SwiftͰݟ͔͚ͨΒ͔͚͍ͯͩ͘͞ɻ
ʢӳޠॿ͚͍ͯͩ͘͞ʣ
੍ͷ͓
੍ͱ • Auto LayoutΛߏ͢ΔͨΊͷʮ݅ʯ • ཁૉͷҐஔ = ׂ߹ * ରཁૉͷҐஔ
+ ڑ Ͱߏ͞ΕΔ • ʮԣ෯ͷத৺ʯʮॎ෯ͷத৺ʯઃఆՄೳ
ྫ͑ɺࠨʹViewΛ ஔ͖͍ͨ߹
7JFXUPQ 7JFXMFBEJOH 7JFXCPUUPN 7JFXXJEUI 4VQFS7JFXXJEUI
͜ΕΛӈʹಈ͔͠·͢
͜ͷ෯͚ͩ ੍Λมߋ͠·͢
ίʔυྫ class ViewController: UIViewController { @IBOutlet var testView: UIView! @IBOutlet
var testViewLeadingConstraint: NSLayoutConstraint! @IBAction func buttonTouchDown(_ sender: Any) { self.testViewLeadingConstraint.constant = self.testView.frame.width } }
None
ಈ࡞֬ೝ
͜ΕʹΞχϝʔγϣϯΛ ͚ͭͯΈ·͢ɻ
animateՃ class ViewController: UIViewController { @IBOutlet var testView: UIView! @IBOutlet
var testViewLeadingConstraint: NSLayoutConstraint! @IBAction func buttonTouchDown(_ sender: Any) { UIView.animate(withDuration: 3.0, animations: { self.testViewLeadingConstraint.constant = self.testView.frame.width }) } }
ಈ࡞֬ೝ
Ξχϝʔγϣϯ͞Εͳ͍ʁʁ
Ξχϝʔγϣϯ͢Δํ๏ class ViewController: UIViewController { @IBOutlet var testView: UIView! @IBOutlet
var testViewLeadingConstraint: NSLayoutConstraint! @IBAction func buttonTouchDown(_ sender: Any) { self.testViewLeadingConstraint.constant = self.testView.frame.width UIView.animate(withDuration: 3.0, animations: { self.view.layoutIfNeeded() }) } } ->΄ͱΜͲͷαΠτͰಉ͡༰͕ग़ͯ͘Δ
Ξχϝʔγϣϯ͢Δ݅ View Programming Guide for iOSΑΓ • UIViewΛ༻ • frame,
boundsͳͲݶΒΕ߲ͨͷΈՄೳ • ConstraintͰઃఆ੍ͨ͠LayoutΛߋ৽͢ Δ·Ͱมߋ͞Εͳ͍ • layoutIfNeededΛݺͿ͜ͱͰஔ͕มΘΔͨ ΊΞχϝʔγϣϯ͞ΕΔʢਪଌʣ
Ԡ༻ʁྫ
ࠨʹViewΛ ೋͭஔ͍ͨ߹
XJEUI IFJHIUڞʹ 4VQFS7JFX XJEUIಉ͡Ͱɺ ্ͷ7JFXͱͷ$POTUBOU͕
Լ͚ͩΛಈ͔ͯ͠Έ·͢
੍ มߋͨ͠ConstantҎ֎ಈ͔ͳ͍
·ͱΊ • ੍IBOutletͰඥ͚Ͱ͖Δ • ੍ΛAnimationͰಈ͔͍ͨ͠߹ layoutIfNeededΛ༻͢Δ • ੍มߋͨ͠෦Ҏ֎ӨڹΛड͚ͳ͍
͋Γ͕ͱ͏͍͟͝·ͨ͠