Questions tagged [nsattributedstringkey]

32 questions
1
vote
1 answer

Issues with NSAttributedString and Button

I'm trying to update a button title field with an NSAttributedString. So I tried to set the attributed title but it's not working properly. It does not display the correct attributed properties I've put into the NSAttributedString. I've come to the…
0
votes
0 answers

Swift NSAttributedString.Key.foregroundColor not working in some older iOS versions

I'm using the below extension while adding multiple colors to UILabel text. Results are showing as expected in iOS 13 and above, While came to know that it causes issues in iOS 12.4 as showing default UILabel text color regardless of any…
0
votes
0 answers

Objective C - Change font of attributed string from HTML text with it's own style

I am dynamically getting an HTML string from Server and parsing it to an Attributed String to show it in my app. Since the string has its own styles, it shows different fonts and sizes, something that is affecting our design choices. Some text is…
0
votes
1 answer

How to set NSAttributedString text color?

I tried to set some attributes to an NSAttributedString. Everything works except for the foreground color. This is how I tried to set the attributes: func setLabelText(text:String){ let strokeTextAttributes = [ …
Dinu Nicolae
  • 1,019
  • 2
  • 17
  • 42
0
votes
2 answers

Change UILabel attributed String color multiple times

I am new to Swift 5 and am doing my first project. I want to change the color of some texts inside my label, this is what my label looks like: "You need to pay attention to blue texts, and even more to red texts. Try again so there is no more blue /…
0
votes
1 answer

How do I change the color of the unselected/normal segment text in an iOS 13 segmented controller?

I am trying to configure an instance of the UISegmentedController class so that I can set the color of the text in the unselected segment from the default of black to white for a two-segment segmented controller. But I can't find any way of doing…
user7142686
0
votes
1 answer

TTTAttributedLabel, change of color works only the first time controller launches in Swift

self.descriptionLbl.text = actionReqdText let labelString = self.descriptionLbl.text as! NSString let contactRange1 = labelString.range(of: actionString1) let contactRange2 = labelString.range(of: actionString2) …
0
votes
0 answers

Add attributes to an already attributed string in textView

I tried all the best to search all possible solution to get this to work. I am wondering if I can change the already attributed text to a new attributed text with other attributes without changing it to string. func updateSelectedText(attributes:…
0
votes
1 answer

Strikethrough horizontal line with words in the middle Swift iOS

I am trying to get this done using AttributedString. Is there a way to have horizontal line with words in the middle?
Bonnke
  • 896
  • 1
  • 12
  • 24
0
votes
1 answer

HTML Text (with Table) in UILabel using NSAttributedString

I was trying to load a simple html string (which has a table) on the UILabel using the attributed string, if the language is english it works well for the rtl layouts the formatting does not work, but it works well on WKWebView, here is the sample …
0
votes
1 answer

How to store and access an 'array' of NSAttributedString.Key.foregroundColor values

I've a grid UICollectionView showing a single text label in each cell. While the figure shows different attributes in each cell, I cannot work out how to store and access specific NSAttributedString.Key.foregroundColor values at the…
0
votes
0 answers

Swift attributed string part colored issue

I'm trying to change the second half of some text to a different color using range. let stringToColor = NSLocalizedString("Plan", comment: "") let mainString = title + ": " + stringToColor let range = (mainString as…
user7684436
  • 697
  • 14
  • 39
0
votes
1 answer

Type 'NSAttributedStringKey' (aka 'NSString') has no member 'foregroundColor'

Below is line of code for the above mentioned issue. This issue is occurred in Swift 4.1. let textAttributes = [NSAttributedStringKey.foregroundColor:UIColor.white] navigationController?.navigationBar.titleTextAttributes = textAttributes
0
votes
1 answer

NSAttributedString with two different text alignments

I'm trying to display some text in a UILabel using attributedText, with 2 different text alignments. I'm fetching the values from Firebase & they are key and value types. For some reason I can't get the title to be aligned left and the subtitle…
r3dm4n
  • 1,175
  • 2
  • 18
  • 33
0
votes
1 answer

Generate dynamic text attribute by pattern

I have a string like this var str = "This is &my& apple, I bought it %yesterday%" Everything inside & & mark will be italics, inside % % mark will turn into bold style and set this data to a UILabel. The final output will be: This is my apple, I…
Shin622
  • 645
  • 3
  • 7
  • 22