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
(iOS13の)UIBarButtonItem 位置調整あるある
Search
domonr
October 23, 2019
Programming
0
980
(iOS13の)UIBarButtonItem 位置調整あるある
domonr
October 23, 2019
Tweet
Share
More Decks by domonr
See All by domonr
アプリのリニューアル時にDomainModelを削除した話(設計カンファレンス extends OOC 2024.3.29)
domonr
0
610
あるあるLT~文字列共通化~
domonr
0
570
あるあるLT_domonr_2019-03-19.pdf
domonr
0
1.4k
脱ぼっちレビュー_domonr
domonr
0
330
Other Decks in Programming
See All in Programming
モバイルアプリにおける自動テストの導入戦略
ostk0069
0
110
Асинхронность неизбежна: как мы проектировали сервис уведомлений
lamodatech
0
600
htmxって知っていますか?次世代のHTML
hiro_ghap1
0
330
事業成長を爆速で進めてきたプロダクトエンジニアたちの成功談・失敗談
nealle
3
1.4k
tidymodelsによるtidyな生存時間解析 / Japan.R2024
dropout009
1
720
testcontainers のススメ
sgash708
1
120
Fibonacci Function Gallery - Part 1
philipschwarz
PRO
0
200
Discord Bot with AI -for English learners-
xin9le
1
120
Cloudflare MCP ServerでClaude Desktop からWeb APIを構築
kutakutat
1
530
Security_for_introducing_eBPF
kentatada
0
110
103 Early Hints
sugi_0000
1
220
アクターシステムに頼らずEvent Sourcingする方法について
j5ik2o
4
160
Featured
See All Featured
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
17
2.2k
BBQ
matthewcrist
85
9.4k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
A Tale of Four Properties
chriscoyier
157
23k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
5
440
Building Adaptive Systems
keathley
38
2.3k
Art, The Web, and Tiny UX
lynnandtonic
298
20k
Visualization
eitanlees
146
15k
Transcript
(iOS13ͷ)UIBarButtonItem Ґஔௐ͋Δ͋Δ ͲΜ/2019/10/23 1
ͲΜ EPNPOS wJ04͙Β͍ͬͯ·͢ wϚϯΨ͖Ͱ͢ ɹ࠷͔ۙΒ͘ΓαʔΧεಡΈ·ͨ͠ 2
(iOS13ͷ) UIBarButtonItem Ґஔௐ͋Δ͋Δ 3
(iOS13Ͱ)UIBarButtonItemͷ ҐஔΛ(OSඪ४ΑΓ)֎ଆʹ͍ͨ͠ 4 σβΠφʔ ͬͯݴΘΕͨΓ͠·͢ΑͶ
5 6pt (OSඪ४8pt or 16pt)
ͳͷͰࠓiOS13ରԠߟྀͨ͠ UIBarButtonItemͷஔʹ͍ͭͯ ൃද͠·͢ 6
UINavigationBarपΓͷ֊ͷઆ໌ 7
8
9 • UINavigationBar ͷ্ʹ UIBarButtonItem ͕ઃஔ͞Ε͍ͯΔܗ • λοϓྖҬҐஔௐ ؆୯
10
11 • UINavigationBar ͷ্ʹUIStackView ͕ஔ͔Εͦͷதʹ UIBarButtonItem ͕ઃஔ͞Ε͍ͯΔܗ • λοϓྖҬҐஔௐ Λ͢Δࡍʹ
UIStackView͕अຐ
12
13 • UINavigationBar ͷ্ʹUIStackView ͕ஔ͔Εͦͷதʹ UIBarButtonItem ͕ઃஔ͞Ε͍ͯΔܗ • ͞ΒʹUIStackView ͕Ṗͷprivate
classʹ ͳ͍ͬͯΔ….
14
֊ΛݟͨΒΘ͔ΔͷͰ͕͢ɺ iOS11͔ΒiOS13ʹ͔͚ͯجຊత ʹมԽ͋Γ·ͤΜɻ 15 ͨͩ͠…
Client error attempting to change layout margins of a private
view 16 ϓϥΠϕʔτϏϡʔͷϨΠΞτϚʔδϯΛมߋ͠ Α͏ͱ͢ΔΫϥΠΞϯτΤϥʔ
Client error attempting to change layout margins of a private
viewͷઆ໌ 17
18 loop: for view in subviews { for stack in
view.subviews where stack is UIStackView { stack.superview?.layoutMargins = .zero break loop } } ্هͷΑ͏ʹSubViewΛճͯ͠layoutMarginsΛௐͨ͠ΒౖΒΕ·͢
ͳͷͰɺiOS13Ҏ߱NavigationBar ্ͷUIStackViewʹରͯ͠ૢ࡞Λ ߦ͏͜ͱ͕Ͱ͖ͳ͘ͳΓ·ͨ͠ 19
20
iOS13Ҏ߱ͷରԠํ๏ 21
͖͞ʹݴ͏ͱ…. iOS12·Ͱprivate viewΛૢ࡞Ͱ͖ͨͷͰɺ ֎ଆ0pt·ͰλοϓൣғΛ૿ͤ·͕ͨ͠ɺ iOS13Ҏ߱ແཧͰͨ͠ 22
23 UIBarButtonItem(barButtonSystemItem: .fixedSpace, target: nil, action: nil)
StackViewͷ࠷ॳͷཁૉΛ UIBarButtonItem(customView: view) Ͱͳ͘ UIBarButtonItem(barButtonSystemIte m: .fixedSpace, target: nil, action:
nil) ʹ͢Δͱ֎ଆ͔ΒͷҐஔ͕8ptʹͳΔ 24
25 8pt
ͪͳΈʹStackViewͷ࠷ॳͷཁૉΛ UIBarButtonItem(customView: view) ʹ͢Δͱ֎ଆ͔ΒͷҐஔ͕16ptʹͳΔ (customViewҎ֎ͷཁૉΛ࠷ॳʹೖΕΕ8ptʹͳΔΒ͍͠) 26
27 class HogeViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad()
self.navigationItem.leftBarleftButtonItems = [ UIBarButtonItem(barButtonSystemItem: .fixedSpace, target: nil, action: nil), UIBarButtonItem(customView: view) ] } }
• iOS13Ҏ߱8ptΑΓ֎ଆʹButtonΛஔ͢Δͷແཧ • UIBarButtonItem(customView:)Λී௨ʹೖΕΔͱ֎ଆ͔Β16ptͷ ҐஔʹͳΔ • UIBarButtonItem(customView:)Ҏ֎ͷ UIBarButtonItem(barButtonSystemItem:)Λ࠷ॳʹೖΕΔͱ8ptʹ ͳΔ •
ΊΜͲ͍͘͞ͷͰUINavigationBarΛΘͳ͍΄͏͕ૣ͍͔ 28 ·ͱΊ
iOS13ͰNavigationBarButtonͷҐஔΛௐ͍ͨ͠ - Qiita https://qiita.com/rd0501/items/8e8254a23d87a9b2fea2 29 ࢀߟ
͓ΘΓ 30