In my apps I draw some custom graphics in-app. These images are drawn into CGContexts then retrieved as UIImages from the context.
Before iPhone 4 life was simple. I simply did something like this:
The problem with this is that it draws at equivalent display resolution, rather than the hardware resolution of the device. So on the iPhone 4 it all looks a bit blocky/pixelated.
The solution is relatively simply. Change the first line to
This works beautifully. My images are now rendered at the correct resolution and everything looks great. The problem is that UIGraphicsBeginImageContextWithOptions was only added in iOS 4.0. I have set my iPhone OS Deployment Target build variable to 3.0 and I don't get any errors/warnings about using this function but that doesn't seem to cover it: on an iOS 3.x device this function will not exist.
So the question is do I need have some sort of conditional to handle this? Week link the references to the function so as the code loads on 3.x without linker errors? Any insight appreciated
Before iPhone 4 life was simple. I simply did something like this:
Code:
UIGraphicsBeginImageContext(size);
CGContextRef c = UIGraphicsGetCurrentContext();
// Do some drawing
UIImage *toReturn = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return toReturn
The problem with this is that it draws at equivalent display resolution, rather than the hardware resolution of the device. So on the iPhone 4 it all looks a bit blocky/pixelated.
The solution is relatively simply. Change the first line to
Code:
UIGraphicsBeginImageContextWithOptions(size,NO,0.0);
This works beautifully. My images are now rendered at the correct resolution and everything looks great. The problem is that UIGraphicsBeginImageContextWithOptions was only added in iOS 4.0. I have set my iPhone OS Deployment Target build variable to 3.0 and I don't get any errors/warnings about using this function but that doesn't seem to cover it: on an iOS 3.x device this function will not exist.
So the question is do I need have some sort of conditional to handle this? Week link the references to the function so as the code loads on 3.x without linker errors? Any insight appreciated