Questions tagged [nsmutableattributedstring]

357 questions
3
votes
1 answer

Justified text with UITextView and NSMutableAttributedString

I'm trying to put a justified text for a UITextView with NSMutableAttributedString, the NSMutableAttributedString is composed of different NSAttributedString because I need bold and regular font, so I append different NSString, this is my…
3
votes
1 answer

NSUnderlineStyleSingle is two pixels

I am trying to get a line below the attributed string on my custom NSView (NSButton attributedString) and I am using the NSUnderlineStyleAttributeName [self addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle)…
nscoding
  • 866
  • 1
  • 6
  • 10
3
votes
0 answers

String with emoji is displaced when using NSForegroundColorAttributeName with iOS 7

when I'm using NSForegroundColorAttributeName with a string that includes an emoji the string is displaced vertically. Here's an example: UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(10, 100, 300, 21)]; label1.text =…
user1896841
2
votes
2 answers

Save a UITextView attributed string to file in SwiftUI

I need to work with attributed strings (NSMutableAttributedString) in SwiftUI to make a simple rich-text editor, and as you might already know, attributed strings are not natively supported in SwiftUI. So I had to work with the old UITextView using…
Adam M.
  • 85
  • 10
2
votes
0 answers

Can't justify NSMutableAttributedString

I've been using NSMutableAttributedString for a while and never ran into any issues... until now. I'm simply trying to justify some text (along with some other properties) in my label. I tried setting the text alignment on the label itself, on the…
mxlhz
  • 1,033
  • 11
  • 21
2
votes
3 answers

Exception is not being caught

Crashlytics reports that the following line is sometimes throwing a NSInternalInconsistencyException: let attrStr = try NSMutableAttributedString( data: modifiedFont.data(using: String.Encoding.unicode, allowLossyConversion:…
TimSim
  • 3,936
  • 7
  • 46
  • 83
2
votes
1 answer

How to use NSMutuableAttributedString in a UITextView?

I am getting the error: Cannot assign value of type 'NSMutableAttributedString' to type 'String?' when trying to put the string into a UITextView. I have read the following article:…
Zenman C
  • 1,653
  • 13
  • 21
2
votes
1 answer

How to disable underlining urls in NSMutableAttributedString for a label

I have a label with attributed text. The text has url link which gets underlined with default blue color. How to remove the url underline style for NSMutableAttributedString? func htmlToAttributedString(_ html: String) -> NSAttributedString? { …
John Doe
  • 2,225
  • 6
  • 16
  • 44
2
votes
2 answers

Remove the colored background of empty spaces of a UILabel that uses NSMutableAttributedString

I would like to know if is it possible, on a UILabel that uses NSMutableAttributedString, to remove the colored background that is set in the empty spaces on the "beginning" of each line, when the align is set to right. Obs.: everything works fine…
Augusto Carmo
  • 4,386
  • 2
  • 28
  • 61
2
votes
0 answers

NSMutableAttributedString from HTML styles li bullets and numbers erroneously

I have added a convenience constructor to NSMutableAttributedString to accept a String of HTML and a font. extension NSMutableAttributedString { // Convert HTML, but override the font. This copies the symbolic traits from the source font, so…
wjl
  • 7,143
  • 1
  • 30
  • 49
2
votes
1 answer

NSMutableAttributedString paragraphStyle not applying

I've added an NSMutableAttributedString to a CATextLayer. All of the attributes are applying except for the paragraphStyle. Any thoughts as to why? Thanks for the help. func createTextLayer() { let textLayer = CATextLayer() textLayer.frame =…
MT1asli8ghwoi
  • 221
  • 2
  • 11
2
votes
1 answer

How to change the allignment of a character in Attributed String

This is what I want to achieve. I used an attributedString, took the range of character $ and applied attributes to it like below way: let str = "$4" let r1 = str.range(of: "$")! let n1 = NSRange(r1, in: str) let atrStr =…
iPeter
  • 1,330
  • 10
  • 26
2
votes
1 answer

iOS Swift Change Particular Text Color Inside Label Programatically

I'm having some search option in my app, which will highlight given word in UISearchBar. Given word may occurs multiple time in label I need t highlight all those words. How it is possible, I have tried with some set of codes but It will highlight…
2
votes
3 answers

NSAttributedString - add writing direction for Arabic Language

I have an html content that i want to show on UILabel. NSAttributedString *attrStr = [[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute:…
2
votes
1 answer

How to programmatically set line height for a UILabel with dynamic text?

I have a UILabel that will vary in number of lines. I'm using a custom font, and want to set the line height of this label to something >1.
Austin Berenyi
  • 1,013
  • 2
  • 13
  • 25