我的图像很少,我希望在全屏显示在iPad上 - 使用相同的图像。和图像大小不一样。有没有办法以编程方式拉伸图像(UIImageView)
谢谢
答案 0 :(得分:0)
要在UIImageView
范围内拉伸图像,您只需设置相应的contentMode。
您可以将UIImageView设置为屏幕大小,并设置内容模式,如下所示
3个选项
// assume iv is an UIImageView the size of screen
// First option stretches your image to the size of the screen
[iv setContentMode:UIViewContentModeScaleToFill];
// Second option scales your image without changing aspect ratio to the largest possible size such that the whole image fits
[iv setContentMode:UIViewContentModeScaleAspectFit];
// Third option scales your image without changing aspect ratio to the smallest possible size such that the screen is covered (potentially clipping some of your image)
[iv setContentMode:UIViewContentModeScaleAspectFill];