Skip to content

Instantly share code, notes, and snippets.

@oocoocococo
Created July 28, 2020 11:43
Show Gist options
  • Save oocoocococo/a83c27b0040927bd3f686cba8b8bac21 to your computer and use it in GitHub Desktop.
Save oocoocococo/a83c27b0040927bd3f686cba8b8bac21 to your computer and use it in GitHub Desktop.
import SwiftUI
struct ContentView: View {
/// スイッチのオンオフ
@State var isOn: Bool = false
/// 選択した日付
@State var selection: Date = Date()
var body: some View {
NavigationView {
Form {
Toggle(isOn: $isOn) {
Text("リマインダー")
}
// スイッチがオンの時に表示する
if isOn {
DatePicker(selection: $selection,
displayedComponents: .hourAndMinute) {
Text("通知する時間")
}
}
Button(action: { }) {
Text("リセット")
}
}
.navigationBarTitle("設定", displayMode: .inline)
.listStyle(GroupedListStyle())
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment