I would like to ask how to scale an image to fill a UIImageView but still keep its aspect ratio, just like the centerCrop scale type of Android ImageView does.
You should use .scaleAspectFill. In swift 4.2:
myImageView.contentMode = .scaleAspectFill
myImageView.clipsToBounds = true // If you want to crop
You can set image view contentMode to UIView.ContentMode.scaleAspectFill. It is equivalent of Android scaleType centerCrop
Following are the main content modes of UIImageView:
the one to fill the whole imageview is 'ScaleAspectFill' plus you can also use 'clipsToBound' property as true so that it will crop the extra image which is out of imageview.