3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Qiita全国学生対抗戦Advent Calendar 2022

Day 22

【SwiftUI】Toggleのスタイルについて

Last updated at Posted at 2022-12-22

はじめに

iOS15からToggleのスタイルが増えてたので整理してみました。

スタイル

iOS

switch

import SwiftUI

struct ContentView: View {
    @State private var isOn = false
    var body: some View {
        Toggle("トグル", isOn: $isOn)
            .toggleStyle(.switch)
    }
}

Simulator Screen Recording - iPhone 14 Pro - 2022-12-22 at 20.45.02.gif

button

import SwiftUI

struct ContentView: View {
    @State private var isOn = false
    var body: some View {
        Toggle("トグル", isOn: $isOn)
            .toggleStyle(.button)
    }
}

Simulator Screen Recording - iPhone 14 Pro - 2022-12-22 at 20.45.55.gif

macOS

switch

import SwiftUI

struct ContentView: View {
    @State private var isOn = false
    var body: some View {
        Toggle("トグル", isOn: $isOn)
            .toggleStyle(.switch)
    }
}

画面収録_2022-12-22_20_51_24_AdobeExpress.gif

checkbox

import SwiftUI

struct ContentView: View {
    @State private var isOn = false
    var body: some View {
        Toggle("トグル", isOn: $isOn)
            .toggleStyle(.checkbox)
    }
}

画面収録_2022-12-22_20_53_54_AdobeExpress.gif

button

import SwiftUI

struct ContentView: View {
    @State private var isOn = false
    var body: some View {
        Toggle("トグル", isOn: $isOn)
            .toggleStyle(.button)
    }
}

画面収録_2022-12-22_20_48_59_AdobeExpress.gif

おわり

iOSにもcheckboxスタイル欲しいですねー

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?