Questions tagged [nsattributedstring]

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.

NSAttributedString and NSMutableAttributedString declare the programmatic interface for read-only attributed strings and modifiable attributed strings, respectively. The Foundation framework defines only the basic functionality for attributed strings; in Mac OS X, additional methods supporting RTF, graphics attributes, and drawing attributed strings are described in NSAttributedString Additions, found in the Application Kit. The Application Kit also uses a subclass of NSMutableAttributedString, called NSTextStorage, to provide the storage for the Application Kit’s extended text-handling system.

In Mac OS X, the Application Kit also uses NSParagraphStyle and its subclass NSMutableParagraphStyle to encapsulate the paragraph or ruler attributes used by the NSAttributedString classes.

An attributed string identifies attributes by name, storing a value under the name in an NSDictionary object. In Mac OS X, standard attribute keys are described in the “Constants” section of NSAttributedString Application Kit Additions Reference. You can also assign any attribute name/value pair you wish to a range of characters—it is up to your application to interpret custom attributes (see Attributed String Programming Guide). If you are using attributed strings with the Core Text framework, you can also use the attribute keys defined by that framework.

Note that the default font for NSAttributedString objects is Helvetica 12-point, which differs from the Mac OS X system font Lucida Grande, so you may wish to create the string with non-default attributes suitable for your application using, for example, initWithString:attributes:.

Resource

2249 questions
0
votes
1 answer

unarchiving NSAttributedString in iOS

I tried archiving an NSAttributedString in Mac OSX 10.7 and then tried to unarchive it in iOS 4.. I get an error: cannot decode object of class (NSParagraphStyle) I see that there's no NSParagraphStyle in iOS. So my question is, is there a…
the Reverend
  • 12,305
  • 10
  • 66
  • 121
0
votes
1 answer

How do you pass a specific font name with font size when making a string bold, italic, underlined, or strikethrough?

I wrote some code to make a string bold, italic, underlined and strikethrough. But while performing these functions, I want to keep a specific font name and size intact and not default it to system values for both font name and font size. How do I…
iosDevSan
  • 65
  • 1
  • 13
0
votes
2 answers

Swift- How to remove attributed string values and make it appear as normal string. (Bold, Italic, Underline, Strikethrough)

I want to remove attributed string values and make it appear as normal string. (Bold, Italic, Underline, Strikethrough) I have added below code to make it attributed but I want to know how do i remove these attributes from the string when clicked on…
iosDevSan
  • 65
  • 1
  • 13
0
votes
1 answer

How to reliably detect if NSParagraphStyle thinks it is (part of) a list?

I have some truly cursed code which detects whether an NSParagraphStyle instance has non-empty "lists", by inspecting the style.description string: attributedString.enumerateAttribute( .paragraphStyle, in: fullLength, options:…
Tikitu
  • 679
  • 6
  • 22
0
votes
1 answer

NSAttributedString background color is not solid when other attributes are applied

I want to make several changes to UILabel text style by using NSAttributedString: Part of the string must have a solid backgroundColor; Some parts of the string must have a different font; Some parts of the string must have a different…
pacification
  • 5,838
  • 4
  • 29
  • 51
0
votes
1 answer

NSAttributedString - Underline colors are not applied correctly

I want to underline and color a text in an UILabel. The underline and the text have a complex pattern of changing colors, but my code sometimes fails. The following minimal code reproduces the issue. let attributedTitle =…
Kei Ishida
  • 27
  • 4
0
votes
0 answers

NSAttributedString - Space is not underlined at the end of each line

I want to underline each space with red, but the space at the end of each line is not underlined for some reason. But the space is there, I can even highlight it: Here is how I created the text view: let textView = UITextView() let text = "word1…
user2547460
  • 87
  • 1
  • 3
  • 11
0
votes
1 answer

How to apply Atrributed String different spacing between lines in swift

I want to apply spacing between first two lines in attributed string and third line should look like paragraph. Expected output : Expected output screenshot Current Implemenation: Current implementaion screenshot Here is the code tried by me. …
0
votes
1 answer

Save and retrieve AttributedString to SQLite3

I have a project in Objective-c in which I am trying to find a way of saving the attributedText from a UITextView to a SQLite3 table. My Project Target OS is 12.1. I am using an object called "MMItem" with a NSData property called…
Paul
  • 79
  • 11
0
votes
2 answers

Cannot remove strikethrough attribute in UILabel inside a UITableViewCell

Here's a simple test code to demonstrate the problem I am having. When the tableView first appears, all its rows have a strikethrough in the text of the cell's default textLabel using attributedString. When I click on a row, it is supposed to remove…
Kaplan
  • 91
  • 1
  • 11
0
votes
1 answer

How to push view controller on click of HyperLink in Swift 5

Hi I have to push a viewController on click of HyperLink. I have NSMutableAttributedString text. that attributed text have two hyperlink examples GoToHomeScreen and aboutUs both are hyperLink on click of aboutUs need to open a link which is working…
0
votes
0 answers

Formatting for NSAttributedString disappears in NSTableCellView / NSTableView when using - (BOOL)tableView:isGroupRow:

I'm working with an application were I'm wanting to combine all cells in an NSTableView to act as a section header for rows below it. One solution I'm working with is to use - (BOOL)tableView:isGroupRow: which works somewhat, but unfortunately the…
Jc Nolan
  • 450
  • 4
  • 15
0
votes
1 answer

Read RTFD data in IOS

I have RTFD data in NSData objects in IOS that I need to read. In MacOSX I just used to read them with NSAttributedString, but now I know that they are not supported in IOS. attribString = [[NSAttributedString alloc] initWithRTFD:note…
the Reverend
  • 12,305
  • 10
  • 66
  • 121
0
votes
0 answers

Convert HTML text to displayable text in swiftUI

I'm currently facing an issue while building my first app as hobby, The problem is that I receive some json data from a web request and this data is divided into arrays, here I decode my data using JSONDecoder() because I want to display the…
0
votes
0 answers

range of selected text is different from range of actual html attributed string

range of selected text is different from the range of actual HTML attributed string, when i select text in textview view it gives the range of selected text whereas in real the attributed string text range is different the tags are read-only…
1 2 3
99
100