iOS Live Activity: can I remove the margins between different expanded segments?

237 Views Asked by At

I've set up a very basic live activity with .leading, .trailing and .bottom segments. I've also applied .contentMargins(.all, 0) to each of them, but when I show the activity there's still a margin between each of the segments:

screenshot

Is there any way for me to remove them? Ideally I'd have no gap between leading/trailing and bottom.

1

There are 1 best solutions below

0
Nitish On

Yes, it is possible.

Inner margins within dynamic island expanded presentation can be removed with a small work around.

You can try using just the bottom area/position. The top margin of ~37pts is the only caveat.

DynamicIsland {
                DynamicIslandExpandedRegion(.bottom) {
                    HStack(){
                        Text("Merged View").font(.title).foregroundColor(.white)
                    }.frame(maxWidth: .infinity)
                        .frame(height:105)
                        .background(.blue.gradient)
                        .cornerRadius(24)
                    }
            }

It will look something like this.

You can alternatively just use leading area/position and use verticalPlacement parameter inside dynamicIsland modifier.

DynamicIslandExpandedRegion(.leading) {
                        HStack(){
                            Text("Merged View").font(.title).foregroundColor(.white)
                        }.frame(maxWidth: .infinity)
                            .frame(height:105)
                            .background(.green.gradient)
                            .cornerRadius(24)
                            .dynamicIsland(verticalPlacement: .belowIfTooWide)
                        }

I hope this helps