iPhone : Getting the size of an image after AspectFt

前端 未结 4 1593
天涯浪人
天涯浪人 2020-12-28 15:04

Real odd one to get stuck on but weirdly I am.

You you have a imageView containing a image. You size that imageView down and then tell it

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-28 15:13

    well .. you have to do some math. you have the size of the original image and you have the size of the image view.. so you can calculate whether it will be resized by the height or the width.

    if you image view is 300x200 and the image is 1024x768 you can calculate which is the limiting factor

    300/1024 = 0.29296875
    200/768 = 0.260416667
    

    so the height is the limiting factor ... the image will be:

    267x200

提交回复
热议问题