简体   繁体   English

UIImage获取视网膜大小

[英]UIImage get retina size

I want to know how can a retrieve a UIImage size, depending on the type of display that I'm using. 我想知道如何根据我所使用的显示类型来检索UIImage大小。

UIImage * refimg = [UIImage imageNamed:@"people-there.png"];
NSLog(@"SIZE: %f",refimg.size.height);

The output is 输出是

SIZE: 62.000000

... on both iPhone 3gs and iPhone 4g. ...在iPhone 3gs和iPhone 4g上。 I have the image "people-there@2x.png" in the same directory as "people-there.png" 我在与“ people-there.png”相同的目录中具有“ people-there@2x.png”图像

How can I get "SIZE: 124.000" on retina display? 如何在视网膜显示屏上获得“ SIZE:124.000”?

Thanks in advance, 提前致谢,

Lucas. 卢卡斯。

UIImage has a scale property that you can use. UIImage具有您可以使用的scale属性。

UIImage * refimg = [UIImage imageNamed:@"people-there.png"];
NSLog(@"SIZE: %f", refimg.scale * refimg.size.height);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM