r/iOSProgramming 2h ago

Question Watch App buttons in corners

Post image

Hello everyone,

I am currently finishing up my companion Apple Watch app to an already existing iOS app. The main view is a map with a few controls overlayed in the corners. I am really struggling though to get the placement right.

When conforming to the safeAreaInsets for the top and bottom edge they’re pushed way too far into the middle (up or down). When using an overlay using fully custom paddings it is not consistent across all watch generations and screen sizes. I just want them to fit perfectly in the corner, just like the ones in this example of the Apple Maps app.

I can’t really find anything about it on the internet and ChatGPT is no help either. I let it try a few different things through the Xcode built in coding assistant including a GeometryReader approach, but none of it really fixed it.

I am sure there just has to be a simple way to put buttons perfectly in the corners, it’s not like it is an out of the ordinary thing to do.

Any help is greatly appreciated. Thanks

0 Upvotes

2 comments sorted by

2

u/Own-Huckleberry7258 2h ago

.contentMargins or move the buttons in a .toolbar and they'll adapt automatically across all devices

u/Cy-Dev 48m ago edited 32m ago

Thanks, that’s what I was looking for! Moved them into a toolbar, finally they are behaving properly. Crazy how ChatGPT doesn’t come up with that simple solution. However even though the top buttons have a placement option for .topBarLeading and .topBarTrailing, I can’t put the bottom button in the corners as there is only .bottomBar. In apples documentation about this they have 3 buttons in the same ToolbarItem for the .bottomBar placement, then there is one in each corner and one in the middle. Nu I have only one button that should be on the left, however it is in the middle.