0

I need to write some formatted text on a image in my current iOS app. I got example how to write text on a image. But I need formatted text. Let me share a example of text, then you guys can give me a suggestion. Here is a sample text (font should be changed)

Programming Contest !!!
   By XYZ company

   When:
   1/1/2013

   Where:
   South Africa

   Time:
   3.10 PM

Please give me a suggestion how I can do this formatted text (color and font will be enter image description herechanged)

Thanks, Arefin

arefin
  • 365
  • 3
  • 17
  • What do you have so far? Are you able to write text that doesn't have the format you want? And what format do you want - a specific font? Text style? – thegrinner May 02 '13 at 16:06
  • First off, if you're actually trying to write on the image, consider instead placing a transparent label or text field in front of it and writing on that. – Hot Licks May 02 '13 at 16:55
  • please check the image, I have edited my post. – arefin May 02 '13 at 17:16

1 Answers1

0

If I understand your question, you're looking for NSAttributedString. There are several existing examples on SO, as well as Apple docs. If you have a specific issue you're struggling with, update your question and we can probably address it.

The following example applies to your question as it currently stands. Borrows heavily from existing SO posts, and assumes the way you're writing text on an image is by combining existing image with a UILabel:

NSMutableAttributedString * testAString = [[NSMutableAttributedString alloc] initWithString:@"Programming Contest !!! By XYZ company"];
[testAString addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:NSMakeRange(0,19)];
[testAString addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:NSMakeRange(23,3)];
[self.textPlaceholderTextLabel setAttributedText:testAString];
Community
  • 1
  • 1
DenVog
  • 4,226
  • 3
  • 43
  • 72
  • IIRC, attributed text can only be used in iOS 6, if that's an issue. – Hot Licks May 02 '13 at 16:56
  • Please check the image in my post, I have added a image as a sample. I need to write this type of text (color, font should be same as image). Thanks... – arefin May 02 '13 at 17:16
  • Good point Hot Licks. Just to be clear, NSAttributedString has been available for a while. It didn't really become useful for things like UILabel until iOS 6. http://stackoverflow.com/a/13389742/306212 – DenVog May 02 '13 at 17:17
  • @DenVog: anything else that you like to share? – arefin May 02 '13 at 17:33