milof
milof

Reputation: 696

How do I overlay an image and some text onto a UIImage?

I am trying to overlay a signature image along with some text on to a fax image. I have the following code that I am using so far:

CGRect faxImageRect = CGRectZero;
CGRect signatureRect = CGRectZero; //need to add a logo and some text here
//faxImage is a fax UIImage
//signature is a Logo UIImage

faxImageRect.size = faxImage.size;
signatureRect.size = signature.size;

// Adjust the signature's location within the fax image
signatureRect.origin = desirableLocation;

UIGraphicsBeginImageContext(faxImage.size);
[faxImage drawInRect:faxImageRect];
[signature drawInRect:signatureRect];
image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

I need to write some text as part of my signature. Arial size 10. How do I do that? I am getting really confused.

Upvotes: 1

Views: 1388

Answers (1)

cxa
cxa

Reputation: 4248

Checkout – drawAtPoint:withFont: of NSString(UIStringDrawing), some code like this should work:

[@"My Signature" drawAtPoint:somePoint withFont:[UIFont fontWithName:@"Arial" size:10.0]];

Upvotes: 1

Related Questions