Returns a scaled CGRect that maintains the specified aspect ratio when within a bounding object.
The width and height ratio (aspect ratio) you want to maintain.
The bounding rectangle you want to fit into.
Returns a scaled CGRect that maintains the aspect ratio specified by aspectRatio that fits withinboundingRect.
This is useful when attempting to fit the naturalSize property of an AVPlayerItem object within the bounds of another CALayer. You would typically use the return value of this function as an AVPlayerLayer frame property value. For example: