Created
March 28, 2024 13:53
-
-
Save chriseidhof/50418cae1e4472a7a99e828c0587e03a to your computer and use it in GitHub Desktop.
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
// | |
import SwiftUI | |
struct ContentView: View { | |
@State var progress: Double = 0 | |
var body: some View { | |
VStack { | |
Slider(value: $progress, in: 0...1) | |
Text("Hello, world") | |
.foregroundStyle(.white) | |
.padding() | |
.frame(maxWidth: .infinity) | |
.background(Color.black) | |
.overlay { | |
GeometryReader { proxy in | |
Color.green | |
.overlay { | |
Text("Hello, world") | |
.foregroundStyle(.black) | |
} | |
.frame(width: proxy.size.width) | |
.frame(width: proxy.size.width*progress, alignment: .leading) | |
.clipped() | |
} | |
} | |
} | |
} | |
} | |
#Preview { | |
ContentView() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment