SwiftUI的毛玻璃效果
记录一下 SwiftUI的毛玻璃效果
import SwiftUI
/*
extension ShapeStyle where Self == Material {
/// A material that's somewhat translucent.
public static var regularMaterial: Material { get }
/// A material that's more opaque than translucent.
public static var thickMaterial: Material { get }
/// A material that's more translucent than opaque.
public static var thinMaterial: Material { get }
/// A mostly translucent material.
public static var ultraThinMaterial: Material { get }
/// A mostly opaque material.
public static var ultraThickMaterial: Material { get }
}
*/
struct BackgroundMatericalsBootCam: View {
let url = URL(string: "https://picsum.photos/200")
var body: some View {
VStack{
Spacer()
VStack{
RoundedRectangle(cornerRadius: 4)
.frame(width: 50, height: 4)
.padding()
Spacer()
}.frame(height: 350)
.frame(maxWidth: .infinity)
.background(.ultraThinMaterial)
.cornerRadius(30)
}.ignoresSafeArea()
.background(
AsyncImage(url: url, scale: 0.2)
)
}
}
#Preview {
BackgroundMatericalsBootCam()
}