'How can I prevent a SwiftUI view from being clipped to the bounds of its parent view?
How can I prevent a SwiftUI view from being clipped to the bounds of its window (or Scene)?
For instance, the code below initially displays a tiny blue circle:
After receiving a click, the circle's frame becomes bigger than its parent, and this is what's displayed:
How could I make it display the big blue circle, without modifying InternalView's frame?
struct ContentView: View {
var body: some View {
InternalView()
.frame(width: 10, height: 20)
}
}
struct InternalView: View {
var body: some View {
Circle().fill(.blue).frame(width: 200, height: 200)
}
}
Solution 1:[1]
like this???
struct ContentView: View {
@State private var size: CGFloat = 50
var body: some View {
Circle().fill(.blue)
.frame(width: size, height: size)
.onTapGesture {
size = 250 - size
}
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ChrisR |



