Created
October 31, 2020 21:37
-
-
Save lhoward/b2edc60db631c788c9d155760c759a09 to your computer and use it in GitHub Desktop.
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
| import SwiftUI | |
| struct IsVisibleModifier: ViewModifier { | |
| @Binding var isVisible: Bool | |
| func body(content: Content) -> some View { | |
| content | |
| .onAppear { | |
| self.isVisible = true | |
| } | |
| .onDisappear { | |
| self.isVisible = false | |
| } | |
| } | |
| } | |
| extension View { | |
| public func isVisible(_ isVisible: Binding<Bool>) -> some View { | |
| return self.modifier(IsVisibleModifier(isVisible: isVisible)) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment