Created
March 6, 2025 12:05
-
-
Save Chronos2500/9ecd391cbc7990424611c0f9092dcc3b to your computer and use it in GitHub Desktop.
ignoreSafeAreaの動的変更のデモ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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