I want to place images in dynamic notch in Swift UI. I put 2 images using Z stack. The 2nd image represents the image that will come to dynamic notch but it does not fit exactly in dynamic notch. How should I draw a view? Thanks.
Notch Screenshot
ZStack {
GeometryReader { geometry in
Image(uiImage: UIImage(named: "bgImage")!)
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: geometry.size.width, alignment: .center)
.frame(height: UIScreen.main.bounds.height)
}
VStack {
Image(uiImage: UIImage(named: "notch")!)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: UIScreen.main.bounds.width)
}
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
}
.ignoresSafeArea()
I want to place images in dynamic notch in Swift UI. I put 2 images using Z stack. The 2nd image represents the image that will come to dynamic notch but it does not fit exactly in dynamic notch. How should I draw a view? Thanks.
Notch Screenshot
ZStack {
GeometryReader { geometry in
Image(uiImage: UIImage(named: "bgImage")!)
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: geometry.size.width, alignment: .center)
.frame(height: UIScreen.main.bounds.height)
}
VStack {
Image(uiImage: UIImage(named: "notch")!)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: UIScreen.main.bounds.width)
}
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
}
.ignoresSafeArea()
Share
Improve this question
edited Mar 12 at 21:02
Aproachate
asked Mar 12 at 21:02
AproachateAproachate
13 bronze badges
2
- I think that can only be done with LiveActivities. – lorem ipsum Commented Mar 12 at 21:36
- Some apps do this without using live activities but I don't understand how they do it. – Aproachate Commented Mar 13 at 19:57
1 Answer
Reset to default 0I think GeometryReader dynamicIsland is not working as expected. That's why the image might not look the way you want it to.