NSAttributedString objects manage character strings and associated sets of attributes (for example, font and kerning) that apply to individual characters or ranges of characters in the string. An association of characters and their attributes is called an attributed string.

learn more… | top users | synonyms

5
votes
0answers
401 views

Workaround Sought for: iOS 6 NSAttributedString Descenders Block Underline

I am using NSAttributedString (and NSMutableAttributeString) for writing to a PDF via UIGraphicsBeginPDFContextToFile. When I output an attributed string with underline attributes, the underline is ...
4
votes
0answers
333 views

NSRangeException Out of Bounds error

I am setting the attributed text of a label, and I am getting this strange error: Terminating app due to uncaught exception 'NSRangeException', reason: 'NSMutableRLEArray ...
4
votes
0answers
437 views

NSAttributedString setFont does not apply to emoji characters

I am using Nimbus NIAttributedLabel class to display text which sometimes contain emoji characters. I set the font size to [UIFont systemFontOfSize:15] but emoji characters seem to ignore that. With ...
3
votes
0answers
192 views

Changing NSBaselineOffsetAttributeName animated for attributeText property

I'm just trying to implement changing the NSBaselineOffsetAttributeName for particular NSRange of my string layouting in UILabel. The problem is I want to make it using some simple animation. Is there ...
3
votes
0answers
471 views

Laying out individual glyphs with Core Text

I'm currently writing an application against the iOS 6.1 SDK. I know that some things in iOS 7 may obviate the need for a solution to my question but in the interest of learning I'm going to ask ...
2
votes
0answers
15 views

Set text color in CFMutableAttributedStringRef and pass to Obj-c

I'm creating a CFMutableAttributedStringRef with attributes and then passing this to Objective-C. return (__bridge NSAttributedString *)myAttributedStringRef; Most attributes like fonts have ...
2
votes
0answers
97 views
+50

Insert long string into UILabel by cutting tail of every substring separated by \n

I need to a have smart multiline cut of my long multiline string of text. Originally I have the following: On the screen above I pointed the narrow region which I actually have for showing the ...
2
votes
0answers
86 views

HTML with <blockquote> tags in TextView

I want to display HTML text with <blockquote> tags in the UITextView. example of HTML: <div> <blockquote class="uncited"> <div> <cite>Nick:</cite> <blockquote ...
2
votes
0answers
643 views

Add attachment image to attributed string in iOS 6

I have spent 3 hours on this but just can't solve it, anybody knows why? please help me! The code below added an image as an attachment to an attributed string, UIImage *img = [UIImage ...
2
votes
0answers
119 views

UILabel NSAttributedString line spacing ignored on iOS7

So basically i have a label with a attributedString that has custom line spacing. It works as it should on iOS6 but not on iOS7 where my spacing is a bit less than the default but not even close to ...
2
votes
0answers
67 views

Trouble with NSAttributedString and NSMuttableAttributedString

I have the following code that keeps crashing and can't find why. @property (nonatomic)NSUInteger numberOfShapes; @property (strong, nonatomic)NSString *shapeInCard; @property (strong, ...
2
votes
0answers
121 views

Animate NSTextAttachment

Is it possible to animate a NSTextAttachment in a UITextView? I tried modifying its bounds but it doesn't seem to produce any effect. NSAttributedString *attributedText = ...
2
votes
0answers
74 views

UITextView: assigning attributedText on iOS 6 leads to unexpected result

I'm trying to implement keywords highlighting using UITextView control. Here is what's performing in UITextView delegate method: - (void)textViewDidChange:(UITextView *)textView { ...
2
votes
0answers
154 views

Attributed string with NSLinkAttribute does not render on the iPhone

We have an attributed string with 3 components, two are basic strings, the third is a link. The string is being rendered by a UITextView. Strangely, the link is invisible on the iPhone, yet renders ...
2
votes
0answers
695 views

Can I use NSBaselineOffsetAttributeName with TTTAttributedLabel?

I've tried to use NSBaselineOffsetAttributeName with TTTAttributedLabel but it seems to have no effect. For example, this does not seem to do anything: [label setText:text ...
2
votes
0answers
133 views

attributed strings with emojis - proper height

I'm trying to get the height of an attributed string. This is working as expected with: [attrString boundingRectWithSize:size options:(NSStringDrawingUsesLineFragmentOrigin | ...
2
votes
0answers
792 views

Apply offset to UILabel text baseline? It is a label of UITableViewCell

I have a UITableView that with some cells that contains only some text. The text in the cells is vertically aligned to the center of the cell but it does not look good because of the font used. The ...
2
votes
0answers
145 views

Letterpress doesn't work with UIColor from a pattern image

I would like to use a an image as the color of an letter-pressed label but something is not working right and I am not sure what. I create the color with UIImage *redImage = [UIImage ...
2
votes
0answers
126 views

How to get current attributed string in non-editable UITextView?

I'm setting the appearance of a UITextView's text in the storyboard via the attributed string properties. However when I try to access it at runtime in order to copy the attributes object, it returns ...
2
votes
0answers
622 views

Xcode 5 Simulator bug - doesn't show NSMutableAttributedString text

I've created an app with the preview version of Xcode 5 that loads items from a Core Data file and shows the title of the items in a UITableView. The app worked fine on the simulator and my device! ...
2
votes
0answers
160 views

UITextView selectedRange returning incorrect value when using attributedText property

I have a UITextView that is using an NSAttributedString via UITextView.attributedText. When I call UITextView.selectedRange it gives incorrect values if the text contains special characters. Anybody ...
2
votes
0answers
326 views

Prevent typingAttributes in UITextview automatically resets?

I am trying to implement a rich text editor with some key word highlight feature. I implemented the UITextviewDelegate in my own class, and changed the attributedText using my predefined styles in - ...
2
votes
0answers
148 views

Strip Images from Pasteboard

Can someone please guide how I can strip images from attributed text on the pasteboard? EXAMPLE I have a UITextView that supports NSAttributedString. If I allow a user to paste something from the ...
2
votes
0answers
447 views

OHAttributedLabel and UITableView

I am using OHAttributedLabel to create a text link inside my UITableViewCell. However, when I am tapping this link, I am having hard time getting the tap through, it seems like I have to hold my ...
1
vote
0answers
33 views

line spacing not working in NSMutableAttributedString?

I have a custom text view which I built with CoreText. I'm setting the attributes on my text in the following manner: self.font = [UIFont fontWithName:self.fontName size:self.fontSize]; ...
1
vote
0answers
34 views

NSAttributedString properties changes after file archiving

I have some NSAttributedStrings to display. The NSAttributedString contains an NSAttachment which is an image with specific size. First time it s been displayed correctly in UITextView. Then I have ...
1
vote
0answers
45 views

Can't calculate the height of the attributed string

I try to solve the issue with the NSAttributedString and the html in it. I try to draw it in the UILabel as the attributed text in the UITableViewCell. I have a html string: <span ...
1
vote
0answers
63 views

Get Appropriate CGRect for an NSAttributedString

As it is clear from the title I'm trying to find the appropriate size for bounds of a UILabel containing an NSAttributedString which contains some images using NSTextAttachment. Before using the ...
1
vote
0answers
83 views

UILabel size incorrect for single line of text with lineSpacing and multiple colors

I'm pretty sure this is actually a UIKit bug but want to get some input to see if I'm missing something silly here. Here is the code I have: // single line with modified line spacing and 2 colors - ...
1
vote
0answers
108 views

ios - edit NSMutableAttributedString while keeping HTML properties

I have a text with HTML format and I want to use this text in my iOS app. I'm using NSAttributedString to maintain the properties the text has via the HTML tags (such as ...
1
vote
0answers
82 views

How do you change the line-spacing of an attributed UILabel in Storyboards?

It's easy enough to do in code, but if I create a UILabel in a Storyboard and set it to attributed text, then change the Spacing or the Line Height properties, neither has any effect on the label's ...
1
vote
0answers
49 views

Multiple NSMutableParagraphStyle in UITextView

In my app i need to show the different paragraph style for each and every paragraph in UITextView. like if for first paragraph that user write has headIndent 10.0 then second paragraph has 26.0 and ...
1
vote
0answers
14 views

Limit the url boundary in UITextView

I have used NSAttributedString in my UITextView, some links are there, however when I touch the screen where is not right on the link but close to it, it will response to my click on the link. How can ...
1
vote
0answers
90 views

How to write and read NSAttributedstring to and from an XML file?

I am trying to write an attributed string to an XML File and later I try to read it out of there. I have found out all values that I read from NSXMLParser are of type NSMutableString. I was ...
1
vote
0answers
127 views

Editing RTF files on iOS

So, with the Text Kit additions to iOS7, it's very easy -- three lines of code -- to make an NSAttributedString from an RTF file. It works great, and even RTFD files work. However, in searching ...
1
vote
0answers
227 views

Parsing NSAttributedString to HTML on iOS 7

I have an NSAttributedString (coming from HTML) that I set for a UITextView. - (void)setHtml:(NSString *)html { NSData *htmlData = [html dataUsingEncoding:NSUTF8StringEncoding]; // Create ...
1
vote
0answers
153 views

NSAttribute string to HTML

I am devloping an application in iOS, and my requirement is to covert HTML string to NSAttributed string and NSAttributed string back to HTML. First part I was able to achieve. But NSAttributed String ...
1
vote
0answers
135 views

Why isn't my NSAttributedString showing up in a UILabel?

I have a UILabel that I update dynamically. There are basically two axes of variation (single vs double line, and whether it represents a missing item). I cannot get the attributed single line (the ...
1
vote
0answers
326 views

Convert HTML to NSAttributedString in iOS - Don't Get Colors in NSAttributed String

I created the iOS 7 method below to convert an HTML string to NSAttributedString. (I do realize initWithString:attributes: should work instead of initWithData:options:documentAttributes:error:; I've ...
1
vote
0answers
109 views

Setting hyphenationFactor on paragraphStyle causes portion of text to not be drawn

I'm creating an app where I render text to the screen with an NSAttributedString. The problem is when I pass in a value to change the hyphenationFactor to 1.0 (I've read and know that iOS currently ...
1
vote
0answers
225 views

Create NSAttributedString from RTF Text File in iOS 6

I need to create an NSAttributedString from an .rtf text file, so that it maintains the text attributes. In iOS 7, I use this code: NSError *error; NSURL *stringURL = [[NSBundle mainBundle] ...
1
vote
0answers
220 views

iOS NSAttributedString emoji transparency/alpha

I'm using an UITextView and want some parts of the text to have transparency. I'm currently using an NSAttributedString with the NSForegroundColorAttribute having the color with the desired ...
1
vote
0answers
91 views

Center character with NSAttributedString

I'm trying to create a NSAttributedString with 3 components: date arrow date in an UITableViewCell, but the arrow won't center. This is my code: NSString *arrow = [[NSString alloc] ...
1
vote
0answers
178 views

Incorrect scrolling UITextView with NSAttributedString

I want to make a synchronized show lyric app and all lyric shown on a UITextView. In order to highlight current lyric I add background color to NSAttributedString of UITextView. All NSRange of lines ...
1
vote
0answers
325 views

NSStringDrawingTextStorage textContainerForAttributedString:containerSize:lineFragmentPadding

Instance method of String to get height of text sizeWithFont:constrainedToSize:lineBreakMode: is deprecated for ios7. So I used boundingRectWithSize:options:context:. But it shows this issue: ...
1
vote
0answers
271 views

Problems with placing NSAttributedString in a PDF

I'm building a PDF document dynamically in an iOS app. I am trying to convert an HTML formatted string to an NSAttributedString, then position it on my PDF document page. If I treat the string as a ...
1
vote
0answers
176 views

Xcode 5 NSAttributedString in UIButton

I using newest Xcode and iOS7. I am trying to set nsattributed string on UIButton without luck. It shows correctly in the preview, but it doesn't apply changes to the actual button (look at the intro ...
1
vote
0answers
200 views

Is Rounded Corners on Attributed Text Background possible?

I attributed Text with different textcolors. For better readability on highlighted text i use backgroundcolor. Is it possible to bring the CALayer Effect of Rounded Corners on this Textarea? Not the ...
1
vote
0answers
191 views

Set NSAttributedString's background color in custom view's drawRect function

I want to draw text with background color in my custom view, but I found that if I add NSBackgroundColorAttributeName attribute to my NSAttributedString , it doesn't appear. when I remove background ...
1
vote
0answers
78 views

Adjust text underline leading

I want to move the underline on a line of text down (away from the text), i,e. adjust the leading. But this doesn't work: NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] ...