-
-
Save sturdysturge/6fb56483b479c29e7a76b0c0589dba87 to your computer and use it in GitHub Desktop.
LinkStyleView
This file contains 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
struct LinkStyleView: View { | |
let urlString = "https://medium.com/better-programming/the-complete-swiftui-documentation-youve-been-waiting-for-fdfe7241add9" | |
var body: some View { | |
Group { | |
if URL(string: urlString) != nil { | |
//The old way to create a Link-style Button | |
Button("Read more") { | |
if let url = URL(string: urlString) { | |
UIApplication.shared.open(url, options: [:], completionHandler: {_ in }) | |
} | |
} | |
} | |
else { | |
EmptyView() | |
.onAppear { assertionFailure("URL was nil") } | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment