Created
October 24, 2024 01:46
-
-
Save takoikatakotako/b3d337885f3245f306a4b1598d5dfc3f to your computer and use it in GitHub Desktop.
SwiftUIでButton内の画像やテキストの色を変えない
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 var bool = true | |
| var body: some View { | |
| VStack { | |
| Text(bool ? "Snorlax" : "Forever") | |
| Button(action: { | |
| bool.toggle() | |
| }) { | |
| HStack { | |
| Image(.icon) | |
| .resizable() | |
| .scaledToFill() | |
| .frame(width: 50, height: 50) | |
| Text("Tap Me!!") | |
| } | |
| .padding() | |
| .border(Color.gray, width: 2) | |
| } | |
| .buttonStyle(PlainButtonStyle()) | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment