Hi! Does anyone know a correct way to do the following:
I have a view which produces a path and I want to fill it either with a color or with a gradient (which are different types).
For this, I have a enum which I pass to the view from the parent view:
enum FillColor {
case color(_ color: Color)
case gradient(color1: Color, color2: Color)
}
Inside a view, I have a path:
var body: some View {
GeometryReader { geometry in
Path { path in
...
}
}
}
I then need to switch and do smth like:
switch color {
case .color(let c):
path.fill(c)
case .gradient(let c1, let c2):
let gradient = ...
path.fill(gradient)
}
Do I create a variable for a Path?
But I need to use GeometryReader as well.
Post
Replies
Boosts
Views
Activity
Hi! I'm trying to implement a slider inside an expanded dynamic island, but the drag gesture seems to be conflicting with a system "drag right" gesture that dismisses the dynamic island.
How can I resolve this conflict?
Hi! How can I implement swiftUI animations on a dynamic island icon? I want to do this:
DynamicIsland() {}
compactLeading: {
Image("my-icon").shineEffect()
} compactTrailing: {
Image("my-icon")
}
Where in shine effect I start the animation on onAppear:
func body(content: Content) -> some View {
content
.onAppear() {
startAnimation()
}
}
In the main app it works, but in the dynamic island it doesn't.