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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:26:45+00:00 2026-06-13T12:26:45+00:00

How can I underline text in a UITextView . I understand that I would

  • 0

How can I underline text in a UITextView. I understand that I would need to create a subclass of UITextView, but what would go under drawRect:?

Thanks.

  • 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-13T12:26:46+00:00Added an answer on June 13, 2026 at 12:26 pm

    Try to use NSAttributedString as follows and set in UITextView. This works for iOS6.

    NSMutableAttributedString *attString = [[NSMutableAttributedString alloc] initWithString:@"Some String"];
    [attString addAttribute:(NSString*)kCTUnderlineStyleAttributeName 
                       value:[NSNumber numberWithInt:kCTUnderlineStyleSingle] 
                       range:(NSRange){0,[attString length]}];
    

    For more info on NSAttributedString check this How do you use NSAttributedString?

    For eg:-

    textView.attributedText = attString;
    

    From apple documentation on UITextView,

    In iOS 6 and later, this class supports multiple text styles through
    use of the attributedText property. (Styled text is not supported in
    earlier versions of iOS.) Setting a value for this property causes the
    text view to use the style information provided in the attributed
    string. You can still use the font, textColor, and textAlignment
    properties to set style attributes, but those properties apply to all
    of the text in the text view.

    attributedText:

    The styled text displayed by the text view.

    @property(nonatomic,copy) NSAttributedString *attributedText
    

    Discussion: This property is nil by default. Assigning a new value to this property also replaces the value of the text property with the same string data, albeit without any formatting information. In addition, assigning a new a value updates the values in the font, textColor, and textAlignment properties so that they reflect the style information starting at location 0 in the attributed string.

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

Sidebar

Related Questions

i am using text-decoration:underline; but text and underline are touching each other.can i increase
I would like to know how i can underline my text within a textbox
How do you underline a text in an XML file? I can't find an
How can I set the font/bold/italic/underline whatever of some text in a JEditorPane? I
How can I underline a text replaced with Cufon?
How can i create a main page with codeigniter? That page should contain a
Is it possible to underline or embolden certain bits of text in a UITextView?
I have an WPF usercontrol that has a TextBox. I set the text Underline
I need a good spell checker library for Java that can spell check a
I would like to add a colored wiggly underline to certain text fragments of

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.