Skip to content

Instantly share code, notes, and snippets.

@oocoocococo
Created August 6, 2020 22:24
Show Gist options
  • Save oocoocococo/a2f96e9dc88fc22cc5a7d0ac7fd0d418 to your computer and use it in GitHub Desktop.
Save oocoocococo/a2f96e9dc88fc22cc5a7d0ac7fd0d418 to your computer and use it in GitHub Desktop.
"name" = "Great Dane";
"favoriteButton" = "Favorite";
"name" = "グレートデーン";
"favoriteButton" = "お気に入り";
import SwiftUI
struct ContentView: View {
var body: some View {
HStack {
Image("Dog001", label: Text("name"))
.resizable()
.aspectRatio(contentMode: .fit)
.frame(height: 80)
VStack(alignment: .leading) {
Text("name")
.font(.headline)
.padding(.bottom, 10)
HStack {
Spacer()
Button(action: {}) {
Image(systemName: "star.fill")
Text("favoriteButton")
} // Button
.padding()
.foregroundColor(Color(UIColor.label))
.background(Color(UIColor.systemBackground))
.cornerRadius(5)
} // HStack
} // VStack
} // HStack
.padding()
.frame(width: UIScreen.main.bounds.width * 0.8)
.background(Color.gray)
.cornerRadius(12)
.padding()
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ForEach(["en", "ja"], id: \.self) { (identifier) in // 言語: 英語、日本語
ContentView()
.environment(\.locale, .init(identifier: identifier)) // 言語の指定
.previewLayout(.sizeThatFits)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment