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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:35:09+00:00 2026-06-18T11:35:09+00:00

I want to format the test in my textview, some texts in bold some

  • 0

I want to format the test in my textview, some texts in bold some thing in italic like that. Is it possible for uitextview?
Right now I’m using webview with HTML strings.
eg:

<html><head><style type=\"text/css\">h3 {color:white;} p {color:pink;} p {text-align: center} p {font-family:helvetica;font-size:20px;}</style></head><body>\
                                         <h3></h3>\
                                         <p><b>some text </b></p>\
                                         <p>Short some text</p>\
                                         <p>Child  Infusion  7.5 to 15 mg/kg/hr<br>ie 7.5 to 15 times weight per hour</p>\
                                         <p>Adult  Infusion  3 to 12 mg/kg/hr<br>ie 3 to 12 mg times weight per hour</p>\
                                         </body></html>
  • 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-18T11:35:11+00:00Added an answer on June 18, 2026 at 11:35 am

    You can use NSAttributedString, Set Text Font, Foreground And Background Colors, StrikeThrough And Shadow etc..

    Attributed strings make an association between characters and their attributes. Like NSString objects, there are two variations, NSAttributedString and NSMutableAttributedString.
    Although previous versions of iOS supported attributed strings, it wasn’t until iOS 6 that controls such as buttons, labels, textfields and textviews defined a property to manage attributes.
    Attributes are applied to a range of characters, so you can for example, set a strikethrough attribute for just a portion of a string. It’s also important to note that the default font for attributed string objects is Helvetica 12-point. Keep this in mind if you set the font attribute for a range other than the complete string.
    The following attributes can be set with attributed strings:
    NSString *const NSFontAttributeName;
    NSString *const NSParagraphStyleAttributeName;
    NSString *const NSForegroundColorAttributeName;
    NSString *const NSBackgroundColorAttributeName;
    NSString *const NSLigatureAttributeName;
    NSString *const NSKernAttributeName;
    NSString *const NSStrikethroughStyleAttributeName;
    NSString *const NSUnderlineStyleAttributeName;
    NSString *const NSStrokeColorAttributeName;
    NSString *const NSStrokeWidthAttributeName;
    NSString *const NSShadowAttributeName;
    NSString *const NSVerticalGlyphFormAttributeName;

    here are some examples

    //-----------------------------
    // Create attributed string
    //-----------------------------
    NSString *str = @"example for underline \nexample for font \nexample for bold \nexample for italics";
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:str];
    
    // Add attribute NSUnderlineStyleAttributeName
    //[attributedString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInt:NSUnderlineStyleSingle] range:NSMakeRange(12, 9)];
    [attributedString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInt:NSUnderlineStyleSingle] range:NSMakeRange(12, 9)];
    
    // Set background color for entire range
    [attributedString addAttribute:NSBackgroundColorAttributeName
                             value:[UIColor yellowColor]
                             range:NSMakeRange(0, [attributedString length])];
    
    
    // Create NSMutableParagraphStyle object
    NSMutableParagraphStyle *paragraph = [[NSMutableParagraphStyle alloc] init];
    paragraph.alignment = NSTextAlignmentCenter;
    
    // Add attribute NSParagraphStyleAttributeName
    [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraph range:NSMakeRange(0, [attributedString length])];
    
    
    
    // Set font, notice the range is for the whole string
        UIFont *font = [UIFont fontWithName:@"Helvetica" size:18];
    [attributedString addAttribute:NSFontAttributeName value:font range:NSMakeRange(35, 4)];
    
    
    
    // Set font, notice the range is for the whole string
    UIFont *fontBold = [UIFont fontWithName:@"Helvetica-Bold" size:18];
    [attributedString addAttribute:NSFontAttributeName value:fontBold range:NSMakeRange(53, 4)];
    
    // Set font, notice the range is for the whole string
    UIFont *fontItalics = [UIFont fontWithName:@"Helvetica-Oblique" size:18];
    [attributedString addAttribute:NSFontAttributeName value:fontItalics range:NSMakeRange(71, 7)];
    
    
    
    // Set label text to attributed string
    [self.mytextView setAttributedText:attributedString];
    

    `

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

Sidebar

Related Questions

I have an JSON data in format of [{product_id:33,amount:1},{product_id:34,amount:3},{product_id:10,amount:1},{username:test}] now I want to fetch
I want to create json data of format like this: { Credential:{ ref1:Test, ref2:test,
I want to format a date object so that I can display strings such
I want to format monetary values in my DataGrid so that they start with
I want to test some of the newer sparse linear solvers and I want
I'm want to make a test app to record some sound and then modify
I want to open a specific file-format with my own jar file. That means:
I want to show my data in the format like below: <table> <tr> <td></td>
my archieved file is in .ipa format, now i want to make a web
I want to test that my controller action is rendering a partial. I've poked

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.