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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:46:25+00:00 2026-06-15T05:46:25+00:00

While playing around with NSAttributedString, I have run into some strange behavior from UITextView.

  • 0

While playing around with NSAttributedString, I have run into some strange behavior from UITextView. Say I have two properties:

@property (weak, nonatomic) IBOutlet UILabel *label;
@property (weak, nonatomic) IBOutlet UITextView *textView;

In the owning controller for these properties, I have the following code:

NSDictionary *attributes = @{NSFontAttributeName : [UIFont systemFontOfSize:20.],
                            NSForegroundColorAttributeName: [UIColor redColor]};
NSAttributedString *as = [[NSAttributedString alloc] initWithString:@"Hello there!" attributes:attributes];


NSMutableAttributedString *mas = [[NSMutableAttributedString alloc] initWithString:@"Hello where?" attributes:nil];
[mas addAttribute:NSForegroundColorAttributeName value:[UIColor yellowColor] range:NSMakeRange(3, 5)];

self.label.attributedText = as;
self.label.attributedText = mas;


self.textView.attributedText = as;
self.textView.attributedText = mas;

When running in the simulator, the label looks (er, use your imagination) as follows, using the system default font:

<black>Hel</black><yellow>lo wh</yellow><black>ere?</black>

The text view looks as follows, using the system font in size 20.0:

<red>Hel</red><yellow>lo wh</yellow><red>ere?</red>

It seems like the text view is combining the attributes from the two attributed strings. I find this a surprising result, and expected it to behave like the label.

I suspect this is a bug. If it is not, how and why does UITextView treat attributedText differently than UILabel?

(XCode Version 4.5.1)

  • 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-15T05:46:26+00:00Added an answer on June 15, 2026 at 5:46 am

    I filed a bug report with Apple. They came back and said that the issue was addressed with iOS 7 beta 1. Verified as fixed.

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

Sidebar

Related Questions

While playing around with some hooks I noticed that the output from the hooks
I came across on a strange behavior of the following code, while playing around
I have been playing around with the Silverlight progressbar a while and no matter
I have been playing around with Threads and Tasks (.net 4) and noticed some
I have been playing around with JavaScript and Canvas for a while. Very often
I have been playing around with -webkit-overflow-scrolling:touch; for a while and I getting randomly
While playing around with eBay .NET SDK, I ran into an issue. I couldn't
Ok, I have been playing around with this for a while and am getting
I have been playing around with code for a while now, and I have
I have been playing around with wf4 for a while. I found various articles,

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.