Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 02-27-2010, 05:44 AM   #1 (permalink)
Registered Member
 
fernan3682's Avatar
 
Join Date: Feb 2010
Location: Valencia
Posts: 11
Exclamation Wrap Text on UIImage

Hi.
I´m new with Iphone SDK and I´d like to generate a UIImage filled with text.
I´ve done it creating a context and using CGContextShowTextAtPoint later but I need this text to be justified.
An UIlabel justified doesn´t help me because the text is not part of the image.

Can someone help me?
Thanks a lot.
fernan3682 is offline   Reply With Quote
Old 02-27-2010, 01:56 PM   #2 (permalink)
N3RD
 
Join Date: Oct 2009
Posts: 201
Default

Quote:
Originally Posted by fernan3682 View Post
Hi.
I´m new with Iphone SDK and I´d like to generate a UIImage filled with text.
I´ve done it creating a context and using CGContextShowTextAtPoint later but I need this text to be justified.
An UIlabel justified doesn´t help me because the text is not part of the image.

Can someone help me?
Thanks a lot.
I would just add an UILabel as a subview to the UIImage.
tychop is offline   Reply With Quote
Old 02-27-2010, 03:02 PM   #3 (permalink)
Registered Member
 
fernan3682's Avatar
 
Join Date: Feb 2010
Location: Valencia
Posts: 11
Default

Hi tychop, thanks for your help.
I´ve already tried that but the result is not a text as part of the image, I mean, if I try to show that UIimage in other UIImageViewer the text doen´s appear.

This is my code:

CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(NULL, width, height, 8, 4 * width, colorSpace, kCGImageAlphaPremultipliedFirst);

CGContextSetRGBStrokeColor(context, 1.0, 1.0, 1.0, 1.0);
CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 1.0);
//White background
CGContextFillRect(context, CGRectMake(0.0, 0.0, width, height));
CGContextSelectFont(context, "Arial", 6, kCGEncodingMacRoman);
CGContextSetTextDrawingMode(context, kCGTextFill);
CGContextSetCharacterSpacing(context,kCGRenderingI ntentDefault);
CGContextSetRGBFillColor(context, 0, 0, 0, 1);
labelInstructions = [[UILabel alloc] initWithFrame:imagen_view2.frame];
labelInstructions.font = [UIFont systemFontOfSize: 16];
labelInstructions.lineBreakMode = UILineBreakModeWordWrap;
labelInstructions.numberOfLines = 0;
labelInstructions.backgroundColor = [UIColor clearColor];
labelInstructions.text = @"..long text string repito long text string..";
[self.view addSubview:labelInstructions];
CGImageRef imageMasked = CGBitmapContextCreateImage(context);
UIImage *resultingImage = [UIImage imageWithCGImage:imageMasked];


Any help, please?
fernan3682 is offline   Reply With Quote
Reply

Bookmarks

Tags
text, uiimage, wrap

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 257
23 members and 234 guests
@sandris, ADY, Dani77, diyora, FAED, fredidf, F_Bryant, HDshot, iDifferent, JamesCahall, JasonR, mer10, Oral B, prchn4christ, Rudy, smithdale87, Speed, spiderguy84, stekki, tgjorgoski, Touchmint, twerner, vigu360
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,880
Threads: 89,228
Posts: 380,754
Top Poster: BrianSlick (7,129)
Welcome to our newest member, @sandris
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:07 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0