Home > Enterprise >  Styling a small toggle switch in SwiftUI like the ones in System Settings on macOS
Styling a small toggle switch in SwiftUI like the ones in System Settings on macOS

Time:12-30

A small SwiftUI toggle switch

I am attempting to style a tiny toggle switch in SwiftUI to match the appearance of the ones used in the System Settings app on macOS Ventura. However, the Toggle view does not appear to provide sufficient customization options for size and appearance.

We all know the code for a regular size toggle switch:

Toggle("Regular Switch", isOn: $isRegular)
    .toggleStyle(.switch)

Is there a way to automatically accomplish this specific appearance in the latest version of SwiftUI? What method is Apple using to achieve this?

CodePudding user response:

Use all sizes supported for a toggle styled like a switch

  • Related