iOS get width height of jpg file

前端 未结 3 2071
谎友^
谎友^ 2021-02-09 21:36

In my iOS app, I\'m downloading jpeg images from the web, and I\'m wondering how to find the correct width and height of the image so I can display it properly in my iOS app.

3条回答
  •  南旧
    南旧 (楼主)
    2021-02-09 22:20

    You can achieve this using UIImage Size property.

    Have a look at below:

    UIImage *image;
    
    NSLog(@'Width=%f and Height: %f',image.size.width, image.size.height);
    

    Store your web image into "image" object and you will get Width & Height of the image.

    Cheers!

提交回复
热议问题