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

Exit 8 for SwiftUI

ojun
April 12, 2025

Exit 8 for SwiftUI

ojun

April 12, 2025
Tweet

More Decks by ojun

Other Decks in Programming

Transcript

  1. Exit 8 for SwiftUI ojun - DeNA co., Ltd. try!

    Swift Tokyo 2025 LT 2025 / 04 / 11
  2. Exit 1 Prevent double taps or simultaneous taps In this

    case, we need to prevent multiple buttons from being tapped simultaneously. However, SwiftUI doesn’t provide a direct API to handle mutual exclusion between buttons.
  3. Exit 1 Prevent double taps or simultaneous taps Set isExclusiveTouch

    to false on the wrapped UIView and all of its child views. If needed, implement a custom gesture recognizer to handle touch exclusivity.
  4. Exit 2 Match the line height to the Text Inside

    the ZStack, there's a Color and an HStack. The HStack contains a Rectangle and a titleView.
  5. Exit 2 Match the line height to the Text This

    UI is similar to what you might see in a train schedule display.
  6. Exit 2 Match the line height to the Text This

    UI is similar to what you might see in a train schedule display. However, you can see that the orange line doesn't match the height of the Text.
  7. Exit 2 Match the line height to the Text By

    creating a structure that conforms to the Layout protocol, you can align their heights.
  8. Exit 2 Match the line height to the Text Applying

    this layout to the original code allows the orange line to match the height of the Text.
  9. Exit 3 Customize the loading indicator Since customization isn't possible

    in SwiftUI, we need to implement it using UIKit.
  10. Exit 4 Dismiss the keyboard on scroll This behavior is

    supported on iOS 16 and later. The keyboard automatically hides when the user scrolls, which simpli fi es the design.
  11. Exit 5 Presenting a share sheet This code works on

    iOS 16 and later. We're currently using UIActivityViewController to show the Share Sheet.
  12. Exit 5 Presenting a share sheet By switching to ShareLink,

    we can eliminate the dependency on UIKit.
  13. Exit 7 Mesh gradient expression Starting from iOS 18, MeshGradient

    makes it easy to implement mesh gradients.
  14. Exit 8 Square Without GeometryReader It's possible to create a

    square without using GeometryReader by leveraging scaledToFit.