Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Better use of SwiftUI

Better use of SwiftUI

TechFeed Experts Night#3 〜 モバイルアプリ開発特集 (#techfeed_experts_night)
https://techfeed.io/events/techfeed-experts-night-3
↑口頭で話している部分が多いのでYouTubeのアーカイブをぜひご覧ください

https://twitter.com/tanakasan2525

Tatsuya Tanaka

September 07, 2022
Tweet

More Decks by Tatsuya Tanaka

Other Decks in Programming

Transcript

  1. struct NoSematicLayoutView: View { var body: some View { VStack

    { Image("Avatar") .resizable() .scaledToFit() Text("Hello, world") .font(.system(size: 28)) } .padding(16) .toolbar { ToolbarItem(placement: .navigationBarTrailing) { Button { // লུ } label: { Text("Done") .bold() } } ToolbarItem(placement: .navigationBarLeading) { Button("Cancel") { // লུ } } } } } ←ϑΥϯταΠζͷ۩ମతͳࢦఆ ←༨നαΠζͷ۩ମతͳࢦఆ ↑↓഑ஔͷ۩ମతͳࢦఆ
  2. struct NoSematicLayoutView: View { var body: some View { VStack

    { Image("Avatar") .resizable() .scaledToFit() Text("Hello, world") .font(.system(size: 28)) } .padding(16) .toolbar { ToolbarItem(placement: .navigationBarTrailing) { Button { // লུ } label: { Text("Done") .bold() } } ToolbarItem(placement: .navigationBarLeading) { Button("Cancel") { // লུ } } } } } ←୺຤ͷจࣈαΠζΛେ͖ͯ͘͠΋൓ө͞Εͳ͘ͳΔ ͜ͷ഑ஔํ๏ͩͱwatchOSͰ͸࢖͑ͳ͍
  3. struct SematicLayoutView: View { var body: some View { VStack

    { Image("Avatar") .resizable() .scaledToFit() Text("Hello, world") .font(.title) } .padding() .toolbar { ToolbarItem(placement: .confirmationAction) { Button("Done") { // লུ } } ToolbarItem(placement: .cancellationAction) { Button("Cancel") { // লུ } } } } } ←ελΠϧͰͷࢦఆ ←σϑΥϧτ஋Ͱͷࢦఆ ↑↓Ϙλϯͷಈ࡞Ͱͷࢦఆ
  4. struct SematicLayoutView: View { var body: some View { VStack

    { Image("Avatar") .resizable() .scaledToFit() Text("Hello, world") .font(.title) } .padding() .toolbar { ToolbarItem(placement: .confirmationAction) { Button("Done") { // লུ } } ToolbarItem(placement: .cancellationAction) { Button("Cancel") { // লུ } } } } } ←ελΠϧͰͷࢦఆ ←σϑΥϧτ஋Ͱͷࢦఆ ↑↓Ϙλϯͷಈ࡞Ͱͷࢦఆ WatchΞϓϦͱͯ͠΋ϏϧυͰ͖Δ