I have a camera taken picture, and I'd like to resize it to the exact size of a view. But... bounds.size on an iPhone 4 does not take account of the retina display.
I'd like a code that can give me the real pixel size of the view, so it can work on any device without having to test / to know the kind of hardware it runs on.
Do you know how I may do this ?
Every view has the contentScaleFactor
property, which is typically 1.0 (3G, 3GS, iPad) or 2.0 (retina screens). Another approach is to use [[UIScreen mainScreen] scale]
, which has the same values.
note to remain compatible with iOS versions prior to 4.0, you have to check if the method is available using respondsToSelector:@selector(contentScaleFactor)
before getting the value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With