nsmutableattributedstring Questions

25

I have a string like this var str = "@text1 this is good @text1" Now replace text1 with another string, say t 1. I am able to replace the text, but i am not able to bold it. I want to bo...
Spatola asked 13/2, 2015 at 9:17

2

I have an attributed string as below to be displayed in a label. let someText = NSMutableAttributedString(string: "This is a sample text with") let imageAttachment = NSTextAttachment() imageAttach...
Veal asked 28/1, 2020 at 5:57

2

I have a string of text of Arabic and English words, I need to add attribute using NSMutableAttributedString and add paragraph styling with NSMutableParagraphStyle. The problem is paragraph style d...

1

Does SwiftUI Text not work with NSTextAttachment? I have this AttributedString: var attributedString: AttributedString { var sampleAttributedString = AttributedString(sampleText) // Apply some bo...

2

Solved

I have AttributedString with emoji like this "🤣🤣🤣 @Mervin tester 🤣🤣🤣" Now I need to find a range of Mervin in this attributed String. let attributedString = NSMutableAttributedString(strin...

11

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...
Machismo asked 20/7, 2016 at 7:20

6

Solved

I've been trying to apply combinations of NSFontAttributes to NSMutableAttributedString's lately and I simply can't find a thorough explanation on how to do it without removing other attributes. ...
Wriest asked 28/12, 2015 at 19:45

3

I have found several crash reports with the reason unexpected start state. My code looks like this: NSRange range = [content rangeOfString:@"<html>"]; if (range.location != NSNotFound) { N...
Folkway asked 23/10, 2017 at 3:8

8

Solved

I try to underline part of a string, for example, a 'string' part in 'test string' string. I'm using NSMutableAttributedString and my solution was working well on iOS7. NSMutableAttributedString *...

2

Solved

I have a UITextField on which I set a current value as attributed text as follows: public var currentValue: NSAttributedString { get { return inputField.attributedText ?? NSAttributedString() } ...
Nitroparaffin asked 14/9, 2020 at 21:52

25

The issue I am having is that I want to be able to change the textColor of certain text in a TextView. I am using a concatenated string, and just want the strings I am appending into the TextView's...
Jurywoman asked 8/8, 2014 at 15:50

3

Solved

I'm having a problem regarding the creation of a prefix inside a UITextField using the new Swift language. Currently I have created the UITextField using the Interface Builder and I have assigned a...
Followup asked 10/2, 2015 at 15:5

3

Solved

I'm making an iOS app that has a UITextView. When closing a parenthesis in that UITextView, I want to highlight to the user which opening parenthesis it pairs to. So far I've done this using an NSM...
Strode asked 19/1, 2015 at 22:6

4

Solved

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 NSM...

3

I have a table view, in which the cells have a label with some attributed text. The text is being set correctly from cellForRowAtIndexPath. The color of the text is being correctly set but the bold...
Tupi asked 9/6, 2015 at 14:10

4

Solved

Can we not convert NSMutableAttributedString to NSString? I have two NSMutableAttributedStrings and I am appending the 2nd string onto 1st as below: [string1 appendAttributedString:string2]; Sin...

7

Solved

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 attr...
Subedit asked 7/8, 2014 at 9:33

3

Solved

I have added some attributes to my buttons attributedTitle let attr = NSMutableAttributedString(string: currTitle) attr.addAttribute(NSStrikethroughStyleAttributeName, value: 2, range: NSMakeRa...

1

Solved

NSMutableAttributedString defines two string replacement methods: func replaceCharacters(in range: NSRange, with str: String) and func replaceCharacters(in range: NSRange, with attrString: ...
Tuatara asked 17/3, 2019 at 14:16

1

Solved

I'm facing a NSInvalidArgumentException exception after upgrading a project to Swift 4.2 (conversion from 4.0). 2018-09-19 15:37:33.253482+0100 <redacted>-beta[3715:1010421] -[Swift._EmptyArr...
Lovash asked 19/9, 2018 at 14:56

2

Solved

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 its midY is even with the word Cuisine like below: How...
Winburn asked 14/9, 2018 at 16:38

2

Solved

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)
Rolon asked 26/5, 2015 at 20:33

2

Solved

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 NSMutableAttributedS...

6

Solved

This code var textSearch="hi" var textToShow="hi hihi hi" var rangeToColor = (textToShow as NSString).rangeOfString(textSearch) var attributedString = NSMutableAttributedString(string:textToShow...
Billups asked 28/11, 2014 at 0:0

3

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 = N...
Bloodthirsty asked 27/4, 2016 at 19:28

© 2022 - 2024 — McMap. All rights reserved.