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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:22:25+00:00 2026-06-13T00:22:25+00:00

Well this seems silly that it can’t be done – you can set a

  • 0

Well this seems silly that it can’t be done – you can set a predefined attributed string to be displayed on a text view with formatting, but you can’t set general formatting to be applied to live typing on a UITextView.

For example, if I do this before typing anything into the text view:

NSString *string = @"Hello world";
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.minimumLineHeight = 50.f;
NSMutableAttributedString *aStr = [[NSMutableAttributedString alloc] initWithString:string];
[aStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0,[string length])];
mainTextView.attributedText = aStr;

Then formatting displays, and when I edit the text with the keyboard, formatting remains.

However, what if I want to start with a blank UITextView and apply formatting to anything the user will type into the view?

I tried setting string = @"" or string = @" ", but neither of those retain formatting. Is there really no way to apply formatting to user input? What’s the point then of a UITextView having an attributed string property?

According to the docs, setting the text property of the UITextView completely wipes off any formatting done by the attributed string. So whatever the solution is, it would have to not directly set textView.text property, but rather only tweak with the attributedText property.

  • 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-13T00:22:26+00:00Added an answer on June 13, 2026 at 12:22 am

    If I understand the question correctly, this is what the typingAttributes property of the UITextView is for.

    That is, you’d want to do something like:

    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    paragraphStyle.minimumLineHeight = 50.f;
    mainTextView.typingAttributes = [NSDictionary dictionaryWithObject:paragraphStyle forKey:NSParagraphStyleAttributeName];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This could very well be another silly question, but I can't seem to find
This code seems to work well, modifying the properties of my button, except the
This seems like a simple thing, but I can't find an answer in the
This seems like it is completely straightforward, but my brain isn't working very well
I know this is going to sound silly but I can't find what's wrong.
I enabled IntelliTrace on an ASP.NET MVC2 app that seems to working very well
This seems trivial enough, but I can't seem to stumble upon the answer. I
I'm sorry to have to bring up this as well. But it doesn't seem
Well this is weird let me describe the scenario I have this mailer define
Well this file was put in the repo by mistake and was deleted and

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.