Questions tagged [nsmutableattributedstring]

357 questions
14
votes
1 answer

NSMutableAttributedString initWithData: causing EXC_BAD_ACCESS on rotation

I display different types of contents in a tableview and calculate the height of each cell using different custom methods, in heightForRowAtIndexPath. One of these custom methods implies converting some html in an NSMutableAttributedString, and then…
macbeb
  • 227
  • 2
  • 11
13
votes
3 answers

How to remove attributes from the NSAttributedString swift?

I have added some attributes to my buttons attributedTitle let attr = NSMutableAttributedString(string: currTitle) attr.addAttribute(NSStrikethroughStyleAttributeName, value: 2, range: NSMakeRange(0, attr.length)) …
12
votes
11 answers

Attributed String Foreground color not working in Swift

I am using the following code to change the foreground color and font of a attribute string using Swift. But the Font changing perfectly without any problem but the foreground color is not changing var checklistText = NSMutableAttributedString() …
Balaji Kondalrayal
  • 1,743
  • 3
  • 19
  • 38
12
votes
3 answers

Highlight just the text in a UILabel

I'm attempting to set the background color/highlight just the text within a UILabel. The issue is that the line breaks and spaces added to the UILabel to keep the text centered are also being highlighted. Notice the spacing before the last line in…
Daniel Storm
  • 18,301
  • 9
  • 84
  • 152
12
votes
2 answers

NSMutableAttributedString: How to delete last character programmatically on iOS?

I have a custom keyboard and I have to perform backspace action on textview having nsmutableattributed string as a text (combination of character and nstextattachments)
Alok Singh
  • 896
  • 6
  • 18
12
votes
4 answers

How to bold some words in my UITextView using NSMutableAttributedString?

I have a UITextView and there are certain words I'm casting with NSString stringWithFormat that I'd like to be bolded. I have looked around Stack Overflow and tried to follow the the postings but I guess I'm not understanding it. Here's what I've…
10
votes
7 answers

Displaying text in a NSScrollView (Swift)

Just started to learn Swift and created a little macOS app in which I want to use a NSScrollView to display an attributed String. I’ve tried: @IBOutlet var ScrollViewOutlet : NSScrollView var attributedString = NSMutableAttributedString(string:…
ixany
  • 5,433
  • 9
  • 41
  • 65
9
votes
2 answers

Change UIAlertController's title fontsize

I'm trying to change the title fontSize in an UIAlertController, but I can't manage how to set my NSMutableAttributedString to the title-property. So for I've been creating the NSMutableAttributedString with the following code: let title =…
9
votes
2 answers

Emoji loss when using NSMutableAttributedString on UILabel

I have got some strange problem while using NSMutableAttributedString for setting text part on UILabel. It shows some bizarre symbol for specific emojis. Here's the code i use and the screenshot of the problem. guard var _comment = comment.comment…
9
votes
3 answers

NSTextStorage subclass can't handle emoji characters and changes font in some cases

I'm subclassing NSTextStorage to do some link highlighting and I've read as much as I can on the topic. Everything works fine until I type the emoji character. My subclass: private let ims = NSMutableAttributedString() override var string: String…
9
votes
4 answers

How do I limit NSTextView to 2 lines?

I'm trying to specify the number of lines for NSTextView. My designer is requesting 2 lines of text max. I've tried NSMutableParagraph style to add the ellipses truncation that I want, but with NSMutableParagraph I can only get NSTextView with 1…
8
votes
1 answer

Why does a multiline UILabel with linespacing remove the 3 dots at the end?

I have a problem with adding linespacing to my UILabel. If I don't use linespacing, I get 3 dots at the end of line 3 if the text is overflowing. UILabel *labelBlurb = [[UILabel alloc] initWithFrame:CGRectMake(marginLeft, 15+20, 295, 60)]; …
Krueger
  • 484
  • 1
  • 5
  • 20
7
votes
2 answers

How to add padding to a NSMutableAttributedString?

I have a label that uses a NSMutableAttributedString to write out the text as: What I want to do is lower the asterisk's top padding so that it's midY is even with the word Cuisine like below: How can I add padding using a…
Lance Samaria
  • 17,576
  • 18
  • 108
  • 256
7
votes
1 answer

iOS - copy all NSMutableAttributedString attributes to another NSMutableAttributedString

I'd like to copy all attributes from one NSMutableAttributedString into a new one. The code i've tried is this: [attrStr enumerateAttribute:NSFontAttributeName inRange:NSMakeRange(0, attrStr.length) options:0 usingBlock:^(id value, NSRange range,…
j2emanue
  • 60,549
  • 65
  • 286
  • 456
7
votes
1 answer

create an attributed string out of plain (Android formatted) text in swift for iOS

I am reading strings out of a Localizable.strings which contains something like that which is basically what you have in an strings.xml of an Android app "testShort" = "A short\ntest with anotherbold text"; The bold and and line feed…
Soko
  • 774
  • 1
  • 7
  • 20
1
2
3
23 24