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 7747449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:31:55+00:00 2026-06-01T10:31:55+00:00

I am adding text incrementally to a wrapping CATextLayer in a UIScrollView . Each

  • 0

I am adding text incrementally to a wrapping CATextLayer in a UIScrollView. Each time I add text, I need to add height to the textLayer and to the scrollView’s contentSize, and adjust the scrollView’s contentOffset.

(The user should be able to use the scrollView to review previous text, but when new text is added, I want to scroll down to it programmatically.)

UIKit’s sizeWithFont: will treat the entire string as though it is on one line, so in order to calculate the height, I need to multiple the size.height returned by the number of lines, as produced by the textLayer’s wrapping.

Trouble is, if I access the string through the textLayer, it won’t contain any extra ‘\n’ or ‘\r’ characters to account for the wrapping.

Surely there is some way I can get the wrapping info? Perhaps dervied from superclass CALayer somehow? Otherwise I’m stuck calculating my own line breaks.

  • 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-01T10:31:57+00:00Added an answer on June 1, 2026 at 10:31 am

    I assume that CATextLayer internally uses Core Text for layout, so you could do the same and use CTFramesetterSuggestFrameSizeWithConstraints to calculate an appropriate height for an attributed string with a given width.

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

Sidebar

Related Questions

I need to write to a very large text file by adding content to
I have a requirement, where I need to provide adding text boxes dynamically. Consider
I am trying to add text to each cell in particular column via Javascript.
I'm adding different text to each cell in UITableView. However when I do that,
Is there a technique for adding a text footer the bottom of each page
I have a django 1.3 project and I'm in the process of adding text
I suspect that adding a certain letter/character to the beginning of my text will
Safari and Chrome seem to be adding extra padding/margins in regards to the text
I am dynamically adding text in a RichTextBox . How can I set Focus
How would I go about adding text to a UITextView without replacing the previous

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.