Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

add text to UIImage

any ideas Stone Preston

2 Answers

what exactly do you want to do? you could just add a label and display it over an ImageView

well imageViews just display images. if you are using storyboards and have an imageView in your view controller, just drag a label out on top of that imageView and double click the label to set the text you want to be displayed

if you need to do this in code you can do something like:

UILabel *textLabel = [[UILabel alloc] initWithFrame:CGRectMake(0,0,20,30)];
textLabel.text = "some text";
textLabel.fontColor = [UIColor blackColor];
[self.view addSubview:textLabel]

and just change the arguments to cgrect make to whereever you need the text label to be. you could use an image view property and use its position to relatively position your label to the imageView

did you connect those properties using your storyboard? what exactly isnt working. you have the right idea