The following will be considered as deprecated in iOS 7: CGContextSelectFont, CGContextShowTextAtPoint. What should I use instead?
You can use [yourString drawAtPoint:aPoint withAttributes:dictOfAttributes];
Docs for that here.
Or you could just add a UILabel
to your view hierarchy.
//begin graphic context UIGraphicsBeginImageContext(imageSize);
//get the context for coreGraphics
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSetTextDrawingMode(ctx, kCGTextFill);
[[UIColor blackColor] setFill];
[@"yourstring" drawAtPoint:CGPointMake(0, 0) withAttributes:@{NSFontAttributeName:[UIFont fontWithName:@"Helvetica" size:17]}];
//make image out of bitmap context
UIImage *outputImage = UIGraphicsGetImageFromCurrentImageContext();
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