Questions tagged [nsmutableattributedstring]

357 questions
4
votes
3 answers

Setting NSForegroundColorAttributeName on an attributed string shifts the text down on iOS 6

I'm using attributed strings in my iOS app to give the text some style: NSDictionary *titleAttributes = @{NSFontAttributeName: [UIFont fontWithName:@"Raleway" size:12], NSForegroundColorAttributeName: …
Alexis
  • 16,629
  • 17
  • 62
  • 107
3
votes
1 answer

Set range of colored text for UISegmentedControl

According to the following documentation (https://developer.apple.com/documentation/uikit/uisegmentedcontrol/1618570-settitletextattributes) I should be able to add attributes to change how it looks for a particular mode. …
3
votes
0 answers

iOS 13 UIAlertController - Color change in attributedMessage and attributedTitle doesn't work

Color change in attributedMessage and attributedTitle doesn't work. Is there a solution for it? Works well on iOS 12 but no longer works on iOS 13. What can be done or is there a solution or a modification? Here's the full snippet: NSString…
3
votes
1 answer

Set Max number of lines to NSMutableAttributedString

I am using two NSMutableAttributedString and making one NSMutableAttributedString from that two. I want to limit the different number of max lines for both attributedString. I searched a lot but nothing found working and a good option. let…
sohan vanani
  • 1,537
  • 1
  • 20
  • 37
3
votes
0 answers

Attributes for empty attributed string

I'm trying to set the font and text color for an attributed string like this: var attributedString = NSMutableAttributedString(string: myText, attributes: [.font : myFont, .foregroundColor: myTextColor]) Later on, I'm adding more text to this…
rodskagg
  • 3,827
  • 4
  • 27
  • 46
3
votes
5 answers

Change attributed text color with link IOS

How I can change the attributed text color from blue to white? When I click on the UITextView the app opens the url, I just need to change the color to white. My code is in C# but I think it can be converted to swift or objective-c easily. I have…
3
votes
0 answers

Remove image (NSTextAttachMent) from NSMutableAttributedString

I am having trouble completely removing an image and all the "meta data" from the NSAttachMent in the NSMutableAttributedString. To give a high level explanation of my scenario - a user can upload an image or text to a social media feed. I use…
user3766198
  • 109
  • 11
3
votes
1 answer

Add 2 lines of attributed string to title of UIButton not working

I have a UIButton. I'm trying to get the buttons title to have 2 lines, and the second line should be smaller than the first. Here's my code: var myMutable = NSMutableAttributedString(string: "someText\n\(someString)", attributes:…
Jessica
  • 9,379
  • 14
  • 65
  • 136
3
votes
2 answers

How to align a logo in a String

The currently code allow me to attach a logo. Like this: But how can I align only the "Logo" sign on the right ? That is what I want: let paragraph = NSMutableAttributedString() let font = UIFont(name: "Helvetica Neue", size:…
user4385051
3
votes
1 answer

Attributed Text boundingRectWithSize returning wrong size

Very simple question, I'm trying to dynamically get the height of a UILabel, and it seems the boundingRectWithSize:options:context: is ignoring my second line. I've pasted the relevant code below: CGSize maximumLabelSize =…
Bill L
  • 2,576
  • 4
  • 28
  • 55
3
votes
5 answers

Replace character in NSMutableAttributedString

This works for a regular NSString: NSString *newString = [myString stringByReplacingOccurrencesOfString:@"," withString:@""]; But there is no such method for NSMutableAttributedString. How could I remove all instances of a comma in an…
soleil
  • 12,133
  • 33
  • 112
  • 183
3
votes
3 answers

Error "NSMutableRLEArray objectAtIndex:effectiveRange:: Out of bounds'"

I have the following code, in which I pass a string with of the type "Hello|r World|g" and the following function converts it into attributedString with "Hello" Being red in color and "World" being green in color. I used this as I am passing each of…
3
votes
1 answer

Change text color of WKInterfaceLabel using NSMutableAttributedString

I'm trying to change text color in WKInterfaceLabel using setAttributedText property. Here's the code: MyRowController *row = [self.interfaceTable rowControllerAtIndex:idx]; NSString *str_tmp = @"Test"; NSMutableAttributedString *text =…
fdlr
  • 101
  • 1
  • 11
3
votes
1 answer

How to get Custom Text Equivalent of NSAttributedString containing UIImage?

I have a chat application where I need to send Images(Emoticons) along with text. Now, I can add image via NSTextAttachment (Below Code) NSTextAttachment *textAttachment = [[NSTextAttachment alloc] init]; NSString *img=[NSString…
3
votes
1 answer

NSMutableParagraphStyle with NSMutableAttributedString

I have a paragraph I'm using NSMutableParagraphStyle to manage line height. Also, I would like to change one word's color in the paragraph, this is the code I'm using but it just change one word color (attributedText is overwrite) how can I fix it??…
Mariam
  • 683
  • 1
  • 11
  • 27