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

  • Home
  • SEARCH
  • 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 8222761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:23:13+00:00 2026-06-07T14:23:13+00:00

I asked a developer (TwoLivesLeft, the creators of Codea) how they did syntax highlighting

  • 0

I asked a developer (TwoLivesLeft, the creators of Codea) how they did syntax highlighting in their app. He replied :

@TD2 the Codea editor is implemented using a UITextView. The
highlighting is done by overlaying subviews in the appropriate
positions — usually UILabels. They are dequeued from a re-use pool,
similar to the way UITableViewCells work. During scrolling, the lines
requiring re-highlighting pull markers out of the pool and lines that
have moved off screen dump their markers back into the pool.

Can anyone explain how I would get the x and y of a certain word?

  • 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-06-07T14:23:15+00:00Added an answer on June 7, 2026 at 2:23 pm

    UITextView conforms to UITextInput, of which a detailed description can be found here.

    Take a look at the required methods “textRangeFromPosition:toPosition:”, “positionFromPosition:offset:”, “positionFromPosition:inDirection:offset:”, and some of the other geometric-based methods in the UITextInput Protocol. Those might provide the functionality you are looking for.

    I have not actually tried to make sure these work the way you want them too, but that looks like its about what you need.

    Let me know if you need any more help!


    UPDATE:

    Here is some sample code of how to do this. I ended up getting the “firstRectForRange:” method to work. This code basically takes the last three letters of the UITextView “textStuff” and highlights it green.

    UITextView *textStuff = [[UITextView alloc] init];
    textStuff.frame = CGRectMake(2.0, 200.0, 200.0, 40.0);
    textStuff.text = @"how are you today?";
    textStuff.textColor = [UIColor blackColor];
    
    UITextPosition *Pos2 = [textStuff positionFromPosition: textStuff.endOfDocument offset: nil];
    UITextPosition *Pos1 = [textStuff positionFromPosition: textStuff.endOfDocument offset: -3];
    
    UITextRange *range = [textStuff textRangeFromPosition:Pos1 toPosition:Pos2];
    
    CGRect result1 = [textStuff firstRectForRange:(UITextRange *)range ];
    
    NSLog(@"%f, %f", result1.origin.x, result1.origin.y);
    
    UIView *view1 = [[UIView alloc] initWithFrame:result1];
    view1.backgroundColor = [UIColor colorWithRed:0.2f green:0.5f blue:0.2f alpha:0.4f];
    [textStuff addSubview:view1];
    

    Result of running this code:

    enter image description here

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

Sidebar

Related Questions

Problem: I'm an app developer and my boss asked me how many times one
I went to the iPhone Developer Tech Talk a few months ago and asked
In a recent question I asked I was directed to this website: http://developer.android.com/design/index.html Amazing
I was asked this in my interview today, I applied for a graduate developer
I should have asked this in Facebook developer forum instead, but somehow I can't
As a .net developer there are times when one is asked to debug at
I am not a c developer, but I have been asked to to compile
I am a single developer and I have a small app that I sell.
I was asked today by a senior developer which doctype I'd use if I
I recently applied for a developer position and the director there asked me to

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.