Skip to content

Instantly share code, notes, and snippets.

View takoikatakotako's full-sized avatar

Kabigon Ono takoikatakotako

View GitHub Profile
@takoikatakotako
takoikatakotako / ContentView.swift
Created October 24, 2024 01:28
SwiftUIで複数行のPickerを作成する
import SwiftUI
struct ContentView: View {
@State var selectedHour = 8
@State var selectedMinute = 30
var body: some View {
GeometryReader { geometry in
HStack {
Picker(selection: $selectedHour, label: EmptyView()) {
@takoikatakotako
takoikatakotako / ContentView.swift
Created October 24, 2024 01:24
SwiftUIで全画面でSheetを表示する
import SwiftUI
struct ContentView: View {
@State var showingCover = false
var body: some View {
VStack {
Button(action: {
showingCover = true
}) {
Text("Tap me!")
@takoikatakotako
takoikatakotako / ContentView.swift
Created October 24, 2024 01:22
SwiftUIでNavigationBarを非表示にする
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationStack {
Text("No Navigation Bar")
.navigationBarTitle("Not Showing Title")
.navigationBarHidden(true)
}
}
@takoikatakotako
takoikatakotako / ContentView.swift
Created October 24, 2024 01:16
SwiftUIでPreviewを横向きにする
import SwiftUI
struct ContentView: View {
var body: some View {
Text("I Love Snorlax Forever!!")
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
@takoikatakotako
takoikatakotako / ContentView.swift
Created October 24, 2024 01:12
端末のシェイクを検知する
import SwiftUI
struct ContentView: View {
@State var message = "Shake Me"
var body: some View {
Text(message)
.onReceive(NotificationCenter.default.publisher(for: .deviceDidShakeNotification)) { _ in
message = "Device Did Shake"
}
@takoikatakotako
takoikatakotako / ContentView.swift
Created October 24, 2024 01:11
SwiftUIでUICollectionViewのようにViewを並べる
import SwiftUI
struct ContentView: View {
let columns = [GridItem(.fixed(80)), GridItem(.fixed(80)), GridItem(.fixed(80)), GridItem(.fixed(80))]
var body: some View {
ScrollView {
LazyVGrid(columns: columns) {
ForEach(0..<100, id: \.self) { number in
Text("\(number)")
@takoikatakotako
takoikatakotako / ContentView.swift
Created October 24, 2024 01:09
スワイプで遷移するチュートリアル画面を作る
import SwiftUI
struct ContentView: View {
var body: some View {
TabView {
ContentViewCell(image: Image(.snorlax))
ContentViewCell(image: Image(.magnemite))
ContentViewCell(image: Image(.psyduck))
ContentViewCell(image: Image(.quagsire))
ContentViewCell(image: Image(.slowpoke))
@takoikatakotako
takoikatakotako / ContentView.swift
Created October 24, 2024 01:00
SwiftUIで閉じることができないモーダルを表示する
import SwiftUI
struct ContentView: View {
@State var showingSheet = false
var body: some View {
Button(action: {
showingSheet = true
}, label: {
Text("Show Modal!")
@takoikatakotako
takoikatakotako / ContentView.swift
Created October 24, 2024 00:59
SwiftUIでアプリ起動時に画面を遷移させる
import SwiftUI
struct ContentView: View {
@State var viewType: ViewType = .launch
var body: some View {
ZStack {
switch viewType {
case .launch:
Text("Launch")
@takoikatakotako
takoikatakotako / ContentView.swift
Created October 24, 2024 00:55
SwiftUIでハーフモーダルを表示する
import SwiftUI
struct ContentView: View {
@State var showingSheet = false
var body: some View {
Button(action: {
showingSheet = true
}, label: {
Text("Show Modal!")