I’m having something really weird going, I’m adding caption to an image and everything works fine on simulator but on the device itself the font is really small…
I have a problem when using this code :
-(UIImage*) drawTextOnPic:(NSString*) bottomText
inImage:(UIImage*) image
{
UIFont *font = [UIFont boldSystemFontOfSize:48];
UIGraphicsBeginImageContext(image.size);
[image drawInRect:CGRectMake(0,0,image.size.width,image.size.height)];
CGRect = CGRectMake(10.0f,10.0f,image.size.width-20.0f, image.size.height);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetShadow(context, CGSizeMake(2.5f, 2.5f), 5.0f);
[[UIColor whiteColor] set];
[bottomText drawInRect:CGRectIntegral(rect) withFont:font lineBreakMode:UILineBreakModeClip alignment:UITextAlignmentCenter];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
Does someone know why it works only on simulator as I expected? BTW, I’m using the SDK for iOS6, Can it be something there?
Is it something with the retina display? How to fix that?
I choose the default font size (on my case it’s 48) and then checked the image size according to some ref size (in my case 640×480), I did that by sqrtf(area(a)/area(ref)) then multiply this result on font size.
That’s the only way it works for me.
Hope that would help others…