struct MaterialExample: View { let colors: [Color] = [.blue, .purple, .pink, .red, .yellow, .orange, .brown] var body: some View { ZStack { LinearGradient(colors: colors, startPoint: .top, endPoint: .bottom) VStack(spacing: 50) { Text("Devtechie") Text("Devtechie") Text("Devtechie") Text("Devtechie") Text("Devtechie") } .font(.title2) .foregroundColor(.secondary) }.edgesIgnoringSafeArea(.all) } }
struct MaterialExample: View { let colors: [Color] = [.blue, .purple, .pink, .red, .yellow, .orange, .brown] var body: some View { ZStack { LinearGradient(colors: colors, startPoint: .top, endPoint: .bottom) VStack(spacing: 50) { Text("Devtechie") .padding() .background(Material.ultraThinMaterial) Text("Devtechie") .padding() .background(Material.thinMaterial) Text("Devtechie") .padding() .background(Material.regularMaterial) Text("Devtechie") .padding() .background(Material.thickMaterial) Text("Devtechie") .padding() .background(Material.ultraThickMaterial) Text("Devtechie") .padding() .background(Material.bar) } .font(.title2) .foregroundColor(.secondary) }.edgesIgnoringSafeArea(.all) } }
.background(Material.thickMaterial, in: RoundedRectangle(cornerRadius: 10.0))
struct MaterialExample: View { let colors: [Color] = [.blue, .purple, .pink, .red, .yellow, .orange, .brown] var body: some View { ZStack { LinearGradient(colors: colors, startPoint: .top, endPoint: .bottom) VStack(spacing: 50) { Text("Devtechie") .padding() .background(Material.ultraThinMaterial, in: RoundedRectangle(cornerRadius: 10.0)) Text("Devtechie") .padding() .background(Material.thinMaterial, in: RoundedRectangle(cornerRadius: 10.0)) Text("Devtechie") .padding() .background(Material.regularMaterial, in: RoundedRectangle(cornerRadius: 10.0)) Text("Devtechie") .padding() .background(Material.thickMaterial, in: RoundedRectangle(cornerRadius: 10.0)) Text("Devtechie") .padding() .background(Material.ultraThickMaterial, in: RoundedRectangle(cornerRadius: 10.0)) Text("Devtechie") .padding() .background(Material.bar, in: RoundedRectangle(cornerRadius: 10.0)) } .font(.title2) .foregroundColor(.secondary) }.edgesIgnoringSafeArea(.all) } }
struct MaterialExample: View { let colors: [Color] = [.blue, .purple, .pink, .red, .yellow, .orange, .brown] var body: some View { ZStack { LinearGradient(colors: colors, startPoint: .top, endPoint: .bottom) VStack(spacing: 50) { viewWithMaterial(text: "DevTechie", subtext: "ultraThinMaterial", material: .ultraThinMaterial) viewWithMaterial(text: "DevTechie", subtext: "thinMaterial", material: .thinMaterial) viewWithMaterial(text: "DevTechie", subtext: "regularMaterial", material: .regularMaterial) viewWithMaterial(text: "DevTechie", subtext: "thickMaterial", material: .thickMaterial) viewWithMaterial(text: "DevTechie", subtext: "ultraThickMaterial", material: .ultraThickMaterial) viewWithMaterial(text: "DevTechie", subtext: "bar", material: .bar) } .foregroundColor(.secondary) }.edgesIgnoringSafeArea(.all) } private func viewWithMaterial(text: String, subtext: String, material: Material) -> some View { VStack { Text(text) .font(.title2) Text(subtext) .font(.subheadline) } .padding() .frame(maxWidth: .infinity) .background(material) } }