Created
August 7, 2019 17:00
-
-
Save PaulWoodIII/e73fc70f3bf73c7702121a9405116ac5 to your computer and use it in GitHub Desktop.
a button displayed as a pill
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //: [Previous](@previous) | |
| import SwiftUI | |
| import PlaygroundSupport | |
| struct PillTextView<U>: View where U : StringProtocol{ | |
| let action: () -> () | |
| let label: U | |
| var body: some View { | |
| Button(action: action, label: { | |
| Text(label) | |
| .font(.caption) | |
| .padding(.horizontal, 10) | |
| .background(Color.red) | |
| .foregroundColor(Color.white) | |
| .cornerRadius(8, antialiased: true) | |
| .frame(width: nil, height: 16, alignment: .leading) | |
| }) | |
| } | |
| } | |
| let viewController = UIHostingController(rootView: | |
| PillTextView(action: { | |
| print("clicked") | |
| }, label: "ForTags") | |
| ) | |
| PlaygroundPage.current.liveView = viewController | |
| //: [Next](@next) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment