Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6025065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:14:52+00:00 2026-05-23T04:14:52+00:00

I have this little problem and I think I am having it due to

  • 0

I have this little problem and I think I am having it due to the lack of my experience in iOS development. Anyways, I am trying to display some preset text as a layer to my plane (one square). I am using OpenGL ES 1.1 and I chose to set UILabel and then to use its layer as my texture. Everything should be ok, but I am having some troubles. Here is how I get the layer:

- (void) convertTextToTexture:(NSString*)text toImage:(UIImage*)image {  

    UILabel *label = [[UILabel alloc] init];

    CGSize size = [text sizeWithFont:[UIFont boldSystemFontOfSize:12]];
    [label setBounds:CGRectMake(0, 0, size.width, size.height)];
    [label setFrame:CGRectMake(0, 0, size.width, size.height)];
    [label setFont:[UIFont boldSystemFontOfSize:12]];
    [label setLineBreakMode:UILineBreakModeWordWrap];
    [label setNumberOfLines:1];
    label.text = text;

    label.textColor =     [UIColor redColor];


    UIGraphicsBeginImageContext(label.frame.size); 
    [label.layer renderInContext:UIGraphicsGetCurrentContext()]; 
    image = UIGraphicsGetImageFromCurrentImageContext(); 
    UIGraphicsEndImageContext(); 
    [label release]; 
}

and I call it like this:

UIImage *image = [[UIImage alloc] initWithData:someData];

[self convertTextToTexture:@"TEXT" toImage:image];

The result is: I always get someData. If I just alloc and init, I get white texture. I think its a simple noobish mistake with using pointers and setting that info. Although in the debugger I noticed that UILabel size is always 0x0.

Thanks for your help and/or opinion.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T04:14:52+00:00Added an answer on May 23, 2026 at 4:14 am

    Your image is a local variable in this method, and gets thrown out when the method ends. I’m not sure exactly what you’re trying to do, but it looks like image is something that this method should be returning:

    - (UIImage *) convertTextToTexture:(NSString*)text {
         // ...
         return image;
    }
    

    And then you’d call it like:

    UIImage * imageOfText = [self convertTextToTexture:@"TEXT"];
    

    and use imageOfText as desired.

    (I say this without a 100% clear idea of what you’re trying to load from data in this case. If you’re generating the image inside the method, you shouldn’t have anything to load in advance.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a trouble with this little problem. Let's say, I have an array,
I have this little problem, that I cannot figure out which arguments to pass
I have this little problem. My client wanted two distinct swf on a web
I have a little problem. This is my code: stackPanelShapesContainer = new StackPanel(); InitializeStackPanle();
Alright, this problem is a little complicated, so bear with me. I have a
I'm having some problem with logic of the comparison of some periods. I have
I’m having a little Architecture problem. In my project I have a Business Logic
Having an interesting little problem with my iPhone app. I have a view with
I really have tried my hardest on this little problem, its been 2 weeks
I'm having this little problem with internet explorer and ajax. So first I used

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.