Skip to content

Instantly share code, notes, and snippets.

@peantunes
Created May 10, 2021 22:30
Show Gist options
  • Save peantunes/dd804748b4946eeb107fa373b971a7ca to your computer and use it in GitHub Desktop.
Save peantunes/dd804748b4946eeb107fa373b971a7ca to your computer and use it in GitHub Desktop.
Aqua button version using View
import SwiftUI
struct AquaButtonView<Content>: View where Content: View {
let color: Color
let content: () -> Content
var body: some View {
content()
.background(
LinearGradient(
gradient: Gradient(
colors: [.white, color.opacity(0.6), .white]),
startPoint: .top,
endPoint: .bottom))
.cornerRadius(12)
.overlay(RoundedRectangle(cornerRadius: 12)
.stroke(color, lineWidth: 2.0))
.shadow(color: color, radius: 6, x: 0.0, y: 6.0)
}
}
struct AquaButtonView_Previews: PreviewProvider {
static var previews: some View {
AquaButtonView(color: .blue) {
Text("My button")
.foregroundColor(.white)
.padding()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment