Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import SwiftUI
struct AquaBrushedMetalShape: Shape {
func path(in rect: CGRect) -> Path {
Path {
path in for _ in stride(from: 0, to: Int(rect.height), by: 5) {
let y = CGFloat.random(in: rect.minY...rect.maxY)
let curveEnd = CGPoint(x: rect.maxX, y: y)
let controlOffset = CGFloat.random(in: -25...25)
let controlPoint = CGPoint(x: rect.midX, y: y + controlOffset)
path.move(to: CGPoint(x: rect.minX, y: y))
path.addQuadCurve(to: curveEnd, control: controlPoint)
}
}
}
}
struct AquaBrushedMetalView: View {
let gradient = Gradient(
colors: [.aquaTransparentWhite,
.aquaTranslucentWhite,
.aquaTransparentWhite])
var body: some View {
ZStack {
Color.aquaGray
AquaBrushedMetalShape()
.stroke(Color.aquaBrushedMetalStroke, lineWidth: 2)
LinearGradient(gradient: gradient ,
startPoint: .leading,
endPoint: .trailing)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment