[英]iOS: I get many `UIImage` from network, how can I know their `aspect ratio`?
How can I get the aspect ratio for the image which comes from the server? 如何获得来自服务器的图像的长宽比?
EDIT:If I get many image
in the network, how can I get them by using async function
? 编辑:如果我在网络中收到很多
image
,如何使用async function
获得它们? and in the block to get their aspect ratio
? 并在块中获得其
aspect ratio
?
Once you download the image, create an UIImage instance by using the downloaded data then through size property, you will be able to determine the height and width of the actual image downloaded : 下载图像后,使用下载的数据创建一个UIImage实例,然后通过size属性,您将能够确定实际下载的图像的高度和宽度:
let image = UIImage(data: <imageDownloadeddata>)
let imgWidth = image.size.width
let imgHeight = image.size.height
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.