ios - How to fit an image into a dynamic notch? - Stack Overflow

I want to place images in dynamic notch in Swift UI. I put 2 images using Z stack. The 2nd image repres

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
Add a comment  | 

1 Answer 1

Reset to default 0

I think GeometryReader dynamicIsland is not working as expected. That's why the image might not look the way you want it to.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744730467a4590437.html

相关推荐

  • ios - How to fit an image into a dynamic notch? - Stack Overflow

    I want to place images in dynamic notch in Swift UI. I put 2 images using Z stack. The 2nd image repres

    22小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信