【UIImageView / Swift】画像が伸びないように比率を固定【画像】
※ img が UIImageView の変数
★縦横比を維持して目一杯広げる。画像の一部がはみ出す場合がある。
img.contentMode = UIViewContentMode.ScaleAspectFill
★縦横比を維持してはみ出さないように広げる。
img.contentMode = UIViewContentMode.ScaleAspectFit
※ img が UIImageView の変数
★縦横比を維持して目一杯広げる。画像の一部がはみ出す場合がある。
img.contentMode = UIViewContentMode.ScaleAspectFill
★縦横比を維持してはみ出さないように広げる。
img.contentMode = UIViewContentMode.ScaleAspectFit