I was chatting with someone earlier having trouble with aspect ratio calculation… (“What is the largest 16:9 rectangle that fits within the screen bounds?”)
I recalled that AVFoundation has a great utility function for this:
AVMakeRect. Not a lot of people know about this hidden gem.
(I blogged about this here: https://benscheirman.com/2018/01/hidden-avfoundation-gem/)