Skip to content

Instantly share code, notes, and snippets.

@PaulWoodIII
Created August 7, 2019 17:00
Show Gist options
  • Select an option

  • Save PaulWoodIII/e73fc70f3bf73c7702121a9405116ac5 to your computer and use it in GitHub Desktop.

Select an option

Save PaulWoodIII/e73fc70f3bf73c7702121a9405116ac5 to your computer and use it in GitHub Desktop.
a button displayed as a pill
//: [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