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
Ruby note Mobile Tech Talk #1
Search
watura
November 19, 2024
0
430
Ruby note Mobile Tech Talk #1
Ruby note Mobile Tech Talk #1
watura
November 19, 2024
Tweet
Share
More Decks by watura
See All by watura
iPhone が数秒おきにクラッシュするんだけど!
watura
0
6
ノートアプリにUndo機能を実装! UndoManager導入ポイント
watura
0
240
Swift Scripting入門
watura
0
120
2つのAuroraクラスタを同期したお話
watura
0
1.5k
Zaim API
watura
1
690
Featured
See All Featured
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
28
4.4k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
29
2k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
17
2.3k
Navigating Team Friction
lara
183
15k
The Cost Of JavaScript in 2023
addyosmani
46
7k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.2k
How STYLIGHT went responsive
nonsquared
96
5.2k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.1k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
The Pragmatic Product Professional
lauravandoore
32
6.3k
Transcript
watura Ruby note Mobile Tech Talk #1
iOS AppΤϯδχΞ • noteʹೖͬͯ2 • ࠷ۙͷझຯʮͳΖ͏ʯখઆΛಡ Ή • Βͳ͍ •
Ξζʔϧਤॻؗͷ࢘ॻ watura
Mobile Tech TalkͰRuby?
watura SwiftUIͰϧϏΛදࣔͯ͠Έͨ
࣍ • ϧϏΛ;Γ͍ͨ • UIViewControllerͰ;Δ • UIViewRepresentableͰ;Δ • CanvasͰඳը͢Δ •
TextRendererͰ;Δ • ͦͷଞ • ·ͱΊ
|ϧϏʬ;Γ͕ͳʭΛ;Γ͍ͨ ϧϏͬͯRubyͬͯॻ͘ΜͩΑ noteͰϧϏ;Ε·͢ ΤσΟλͰೖྗதͱ͔ʹϧϏදࣔͰ͖Δͱ͍͍ΑͶʁ ͰɺiOSΞϓϦͰϧϏͬͯεϜʔζʹ͑ΔͷͩΖ͏͔ʁ
·ͱΊ • CoreText ͳΒͰ͖Δ • UIKitͰ;ΕΔ • ᘳͱݴ͍͕͍ͨ • SwiftUIͷΈͰ;Γ͍ͨʁ
• ͦΜͳػೳଘࡏ͠ͳ͍ • TextࠈɾTextRenderer
4ͭͷํ๏ • UIViewControllerͰ;Δ • UIViewRepresentableͰ;Δ • CanvasͰඳը͢Δ • TextRendererͰ;Δ
UIViewControllerͰ;Δ UIViewControllerͱ͍͏͔CoreText CTRubyAnnotationCreateWithAttributes(_:_:_:_:_:) • දࣔ͢Δจࣈ • දࣔ͞ΕΔҐஔදࣔํ๏ • ϕʔεͷจࣈ෯ʹ߹Θͤͯදࣔͱ͔ •
ϧϏ͕͗͢Δͱ͖ͷॲཧํ๏ • ϧϏͷදࣔҐஔʢ্Լͱ͔ʣ
UIViewControllerͰ;Δ CTRubyAnnotationCreateWithAttributesΛNSAttributedStringͷ Attributeʹ͍ΕΔ͚ͩ
UIViewControllerͰ;Δ UITextViewͱ͔UILabelͰදࣔ͢Ε͍͍ΜͰ͠ΐʁ ߦؒͱ͔inset͕ਖ਼͘͠ࢦఆͰ͖͍ͯͳ͍
UIViewControllerͰ;Δ LineHeightMultipleͱ͔ContentInsetͱ͔ ϑΥϯταΠζʹΑͬͯม͑Δ
UIViewRepresentableͰ;Δ UIViewControllerͰΔͷͱಉ͡ ՃɿඳըαΠζʹ͋ΘͤͯεΫϩʔϧͱ͔ௐඞཁ
SwiftUI͡Όͳ͍Αʁ
CanvasͰඳը͢Δ ຊ໋ʁ ͢·͵ɻSwiftIU͡Όͳ͍ɻ SwiftUIͱ͍͏͔CoreGraphics CoreGraphics == kCTRubyAnnotationAttributeNa me ͕ࣄΛ͢Δ
CanvasͰඳը͢Δ
CanvasͰඳը͢Δ • ࠲ඪܥͷҧ͍ • εΫϩʔϧ • ඳըྖҬͷαΠζ • CoreTextΛͦͷ··͔ͩΒʁ •
ߦؒͱ͔ͷௐͳ͠ͰΩϨΠ
࠲ඪܥͷҧ͍ ͻͬ͘Γฦͯ͠ɼཪฦ͢తͳ ಛੑ CoreGraphics (CG) UIKit ݪͷҐஔ ࠨԼ ࠨ্ Y࣠ͷ͖
Լ͔Β্ਖ਼ ্͔ΒԼਖ਼ X࣠ͷ͖ ࠨ͔Βӈਖ਼ ࠨ͔Βӈਖ਼ CoreGraphics (CG) UIKit
TextRendererͰ;Δ iOS 18Ҏ্ iOS18Ҏ্ʂʂ ͋ͱ2͘Β͍ϓϩμΫγϣϯͰ͑ͳ͍ʁ
TextRendererͰ;Δ • SwiftUIͷTextΛඳը͢Δͱ͖ʹհೖͰ͖Δ • ΦϨΦϨϨϯμϦϯά͕Ͱ͖Δ • ଠࣈ • ৭ •
എܠ৭ • ࠲ඪ • Ξχϝʔγϣϯ खಈͰϧϏඳըͪ͠Ό͍͍͑Μͩʂʂ
ྗਚ͖ͨͷͰΞυϕϯτΧϨϯ μʔͰهࣄʹ͢Δʂʂ
Canvasͱಉ͡Α͏ͳͬ ͺΓൃੜ͠·͢
ͦͷଞ • খ͞ͳϑΥϯταΠζͷ TextͱຊจTextΛVStackʹ ͢Εʂʂʂ • ҙ֎ͱಈ͖·͢ • ϑϧSwiftUI
ؾ߹͍ͷTextࠈ • TextͷαΠζΛܭࢉ • ಉ͡ߦʹೖΔͳΒHStackʹ͍ΕΔ • ೖΒͳ͍ͳΒɺ৽͍͠HStackʹ͍ΕΔ • ϧϏͳͱ͖̎ஈʹͨ͠ViewΛHStackʹ͍Ε Δ
ͱ͍͏ྲྀΕ • ࡉ͔͍ϨϕϧͰαΠζܭࢉ͕͍ΔͷͰॏ͍ • ͍͍͔Μ͡ʹͰ͖ͨΒɺ͋Γͳͷ͔Ε ͳ͍ ࡞ ͩΕ͕ Λ͡Ίɺ ͦ͏͘͞ ଓ ͭͮ ͚ΒΕΔΑ͏ʹ͢Δɻ
·ͱΊ • CoreTextͳΒͰ͖Δ • ॎॻ͖Ͱ͖ͨΓ͢Δ • UIKitͷੈքͳΒ;ΕΔ • ᘳͱݴ͍͕͍ͨ •
SwiftUIͷΈͰ;Γ͍ͨʁ • ͦΜͳػೳଘࡏ͠ͳ͍ • TextࠈɾTextRenderer
• CTRubyAnnotationCreateWithAttributes(_:_:_:_:_:) • https://developer.apple.com/documentation/coretext/1642000- ctrubyannotationcreatewithattrib • Canvas • https://developer.apple.com/documentation/swiftui/canvas •
GraphicsContext • https://developer.apple.com/documentation/swiftui/graphicscontext • Core Graphics • https://developer.apple.com/documentation/coregraphics • TextRenderer • https://developer.apple.com/documentation/SwiftUI/TextRenderer • textRenderer(_:) • https://developer.apple.com/documentation/swiftui/view/textrenderer(_:) • αϯϓϧίʔυ • https://gist.github.com/watura/08b06ad ff d79cab32be76eb0804306c1