Skip to content

Instantly share code, notes, and snippets.

@swiftui-lab
Last active March 16, 2022 09:39
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swiftui-lab/e35bd98a0eada970e9274fcb020c47f0 to your computer and use it in GitHub Desktop.
Save swiftui-lab/e35bd98a0eada970e9274fcb020c47f0 to your computer and use it in GitHub Desktop.
// The SwiftUI Lab: https://swiftui-lab.com
import SwiftUI
struct ContentView: View {
var body: some View {
Text("hello world!")
.padding(20)
.addBorder(Color.blue, width: 3.0, cornerRadius: 80)
}
}
extension View {
public func addBorder<S>(_ content: S, width: CGFloat = 1, cornerRadius: CGFloat) -> some View where S : ShapeStyle {
return overlay(RoundedRectangle(cornerRadius: cornerRadius).strokeBorder(content, lineWidth: width))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment