Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect rounded screen corners in iOS

On (https://developer.apple.com/ios/human-interface-guidelines/overview/iphone-x) Apple tells us that "A full-width button appearing at the bottom of the screen looks best when it has rounded corners and is aligned with the bottom of the safe area..."

So I want to round the corners of my button if the corners of the screen are round, but have sharp corners when the screen corners are sharp.

I would just check to see of the app is running on an iPhone X, but I expect that future devices will also have rounded corners and I don't want to have to revisit this code every time a new device comes out.

I have already checked window.layer.cornerRaidus in my app delegate...

like image 954
Daniel T. Avatar asked Oct 20 '25 20:10

Daniel T.


1 Answers

Instead of detecting rounded corners, detect a non-zero region under bottom safe area. If this region is big enough, align to it (but obviously not in it), and perhaps round the button corners as your random bet on the future. If not, leave the standard auto-layout bottom margin under your button and use the standard button UI.

Whatever you do, be aware the Apple might or will change their UI guidelines and UI APIs and appearances, so don't plan on your future-proof design being future-proof.

like image 120
hotpaw2 Avatar answered Oct 23 '25 11:10

hotpaw2



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!