Skip to content

Instantly share code, notes, and snippets.

@prafullakumar
Created August 25, 2020 15:24
Show Gist options
  • Save prafullakumar/2bef18171b363af2b1e233e615c9883f to your computer and use it in GitHub Desktop.
Save prafullakumar/2bef18171b363af2b1e233e615c9883f to your computer and use it in GitHub Desktop.
import SwiftUI
enum StylesSet {
struct CustomButton: PrimitiveButtonStyle {
func makeBody(configuration: Configuration) -> some View {
Button(configuration)
.padding()
.frame(minWidth: 0, maxWidth: .infinity)
.background(LinearGradient(gradient: Gradient(colors: [Color.red, Color.green]), startPoint: .leading, endPoint: .trailing))
.cornerRadius(40)
}
}
}
struct CustomViews: View {
var body: some View {
NavigationView {
List {
Button(action: {
}, label: {
Text("Demo Button").foregroundColor(.white)
}).buttonStyle(StylesSet.CustomButton())
}
.navigationTitle("Styling Demo")
}
}
}
struct CustomViews_Previews: PreviewProvider {
static var previews: some View {
CustomViews()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment