Aspect fit programmatically in iOS?
问题 I want to insert one view into another with aspect fit option. But I can't just set contentMode for some reasons. Could you provide a solution via resizing of the inner CGRect according to the outer CGRect ? And yes, there are a lot of similar questions but no one provides such solution. 回答1: I wrote a function that should achieve what you desire. It will return the CGRect of a given innerRect , after scaling it to fit within a given outerRect , while maintaining aspect ratio. The innerRect