Skip to content

Instantly share code, notes, and snippets.

@takoikatakotako
Created October 24, 2024 00:23
Show Gist options
  • Select an option

  • Save takoikatakotako/a3d3a78b3292dd7b489502dcbb5fb9ff to your computer and use it in GitHub Desktop.

Select an option

Save takoikatakotako/a3d3a78b3292dd7b489502dcbb5fb9ff to your computer and use it in GitHub Desktop.
SwiftUIでViewの上にViewを重ねる
import SwiftUI
struct ContentView: View {
var body: some View {
Image(.icon)
.resizable()
.frame(width: 200, height: 200)
.overlay(
Text("@takoikatakotako")
.foregroundColor(Color.white)
.font(Font.system(size: 20).bold())
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity)
.background(Color.black)
.opacity(0.5)
)
}
}
#Preview {
ContentView()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment