Skip to content

Instantly share code, notes, and snippets.

@jonahaung
Created February 24, 2020 14:32
Show Gist options
  • Save jonahaung/d65fda1e8374bbe504044274bcfb2321 to your computer and use it in GitHub Desktop.
Save jonahaung/d65fda1e8374bbe504044274bcfb2321 to your computer and use it in GitHub Desktop.
SwiftUI Custom Button
//
// CButton.swift
// Myanmar Lens
//
// Created by Aung Ko Min on 24/2/20.
// Copyright © 2020 Aung Ko Min. All rights reserved.
//
import SwiftUI
struct CButton<WhateverYouWant: View>: View {
let action: () -> Void
let content: WhateverYouWant
init(_action: @escaping () -> Void, @ViewBuilder _content:() -> WhateverYouWant) {
action = _action
content = _content()
}
var body: some View {
Button(action: {}) {
content
.padding()
.frame(minWidth: 0, maxWidth: .infinity)
.background(Capsule().fill(Color.blue))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment