0

I have a ViewController that has a UIImageView as a background. What is the proper way to add a label on top of the image if I have the coordinates? My program is adding additional images on top of the UIImageView with:

UIGraphicsBeginImageContext(self.myBackground.image.size);

[newImage drawAtPoint: point];

// Draw a textlabel below the new image

// Some additional code

I have managed to draw the new Image on top of the original, but I don't know how to add the label.

Hank

iHank
  • 526
  • 9
  • 22
  • possible duplicate of [How to write text on image in objective-c iPhone?](http://stackoverflow.com/questions/6992830/how-to-write-text-on-image-in-objective-c-iphone) – Daniel Romero Apr 10 '14 at 08:52

2 Answers2

0
[@"YOUR TEXT" drawAtPoint:point withFont:[UIFont boldSystemFontOfSize:15.0]];
iphonic
  • 12,615
  • 7
  • 60
  • 107
0

You can use addSubview: method for UIImageView to add label or any other subview. Set up label frame to be relative to uiimageview and add it as a subview:

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 50)];
// To use point you can specify label size and after that you can set center:
label.center = point;
//set up other label properties
[self.myBackground addSubview:label];
//I assume self.myBackground is type of UIImageView
Greg
  • 25,317
  • 6
  • 53
  • 62