I'm trying to animate in a view the bottom of its parent view. This is relatively easy to do by animating the offset, like so:
struct ContentView: View {
@State var isShowingBanner = true
var bannerOffset: CGFloat {
isShowingBanner ? 0 : 60
}
var body: some View {
VStack {
VStack {
Spacer()
BannerView()
.offset(y: bannerOffset)
}
.border(Color.black, width: 1.0)
.clipped()
Spacer()
Button("Toggle Banner") {
withAnimation {
isShowingBanner.toggle()
}
}
}
.padding()
}
}
The glaringly obvious problem is that this just uses an arbitrary value for the animated offset, and this quickly breaks when considering dynamic type
My question is:
Is there a way to properly determine the height of BannerView to correctly adjust this animation. Or is there a better way to achieve this effect?
Thanks all


