Если путь заполнен материалом< /code>, он просто заполняется (почти) сплошным черным цветом вместо обычного полупрозрачного эффекта:
Код: Выделить всё
struct ContentView: View {
let loremIpsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
var body: some View {
ZStack {
HStack(spacing: 0) {
Color.clear
Color.orange
}
Text(loremIpsum)
.font(.title2)
.padding()
RoundedRectangle(cornerRadius: 10)
.fill(.ultraThinMaterial)
.frame(width: 200, height: 100)
.padding(.bottom, 160)
Canvas { ctx, size in
let path = Path(
roundedRect: CGRect(
x: (size.width - 200) / 2,
y: (size.height - 100) / 2 ,
width: 200,
height: 100
),
cornerRadius: 10
)
ctx.fill(path, with: .style(.ultraThinMaterial))
}
.padding(.top, 160)
}
}
}

Я пробовал также используется .palette, но тогда эффект Material игнорируется (размытие отсутствует):
Код: Выделить всё
ctx.fill(path, with: .palette([
.color(white: 0, opacity: 0.2),
.style(.ultraThinMaterial)
]))

Как можно GraphicsContext будет использоваться для заполнения Path стилем Material, чтобы придать обычный полупрозрачный эффект?
Подробнее здесь: https://stackoverflow.com/questions/785 ... rial-style
Мобильная версия