Skip to content

Instantly share code, notes, and snippets.

@Chronos2500
Created March 6, 2025 12:05
Show Gist options
  • Save Chronos2500/9ecd391cbc7990424611c0f9092dcc3b to your computer and use it in GitHub Desktop.
Save Chronos2500/9ecd391cbc7990424611c0f9092dcc3b to your computer and use it in GitHub Desktop.
ignoreSafeAreaの動的変更のデモ
import SwiftUI
struct ContentView: View {
@State private var ignoreSafeArea = false
var body: some View {
ZStack {
Color.blue
.ignoresSafeArea(edges: ignoreSafeArea ? .all : [])
VStack {
Spacer()
Button(action: {
ignoreSafeArea.toggle()
}) {
Text("Toggle Safe Area")
.padding()
.background(Color.white)
.cornerRadius(10)
}
.padding(.bottom, 50)
}
}
.animation(.default, value: ignoreSafeArea)
}
}
#Preview {
ContentView()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment