Questions tagged [attributedstring]
27 questions
0
votes
0 answers
Swift 5: UITextField attributedText doesnt update when currency change
I have this CurrencyTextfield which is a CurrencyTextFieldRepresentable because I'm using it inside a SwiftUI view.
I have an attributed string that I am updating in the init into setStyles() and in editingChanged(), the problem in when I change the…

akitainu22
- 95
- 1
- 8
0
votes
1 answer
I want to Localize an AttributedString from my Storyboard but XCode only localizes plain text strings. Is it possible?
I've created a new project to test my real scenario, the thing is simple. I have a UILabel on my Storyboard selected as Attributed and changed some attributes like font and foreground color in order to simulate my real case. Then, added a new…

Yisus
- 159
- 1
- 4
0
votes
0 answers
Value of type 'Text' has no member 'lineHeightMultiple' error message
I want to decrease line height for Text elements in my SwiftUI project. I use the following code and it works fine:
Text("Hello world!\nHello world!")._lineHeightMultiple(0.83)
The problem with the modifier is that it is deprecated and I get the…

Nikita Tepliakov
- 61
- 7
0
votes
0 answers
How to retrieve a UIFont from an AttributedString run.font
I have the following code as an extension to AttributedString:
func setBold() -> AttributedString {
var newAS = self
for run in runs {
if let font = run.font { newAS[run.range].font = font.bold() }
else { // assume NSFont
…

Joseph Levy
- 157
- 8
0
votes
0 answers
Swift AttributedString font size resized by .76666 (recurring) when saved to RTF via NSAttributedString
iOS 16.2. XCode 14.2.
Block below is a simple AttributedString creation and save.
The two AttributedExtensions functions for custom append() and Bold().
The text is saved as an RTF file using NSAttributedString.
I have removed error checking.
var…

tridiak
- 27
- 3
0
votes
1 answer
How to display a diff UI with AttributedStrings
I'm working on a feature that compares a new input to an old input. I'd like it to look like a git diff as seen in bitbucket or github, etc.
I currently have an array of characters with a prefix as to whether they were added or removed. Now I'm…

tim_d
- 133
- 2
- 11
0
votes
0 answers
UITextView Scrolling Up And Down Upon Typing New Line or Character
I have a UITextView. It reads its text string and parses the markdown and displays it on screen using NSAttributedString from AttributedString.
The Problem
When the text is short, it's all good. But when the text is long beyond maybe 2 screen…

Goatt
- 111
- 8
0
votes
0 answers
Appearance contradicts Code, In Simple AttributedString NSParagraphStyle Displayed In UITextView
I'm trying to parse a markdown string manually and create an attributedString for UITextView
When I try to format code blocks, I found some weird bug that I can't solve. I've reduced the problem to this minimum amount of demo code. I hope someone…

Goatt
- 111
- 8
0
votes
1 answer
How do I get line heights of UITextView when using UIStringAttributes in Xamarin Forms iOS?
I have a problem with setting UIStringAttributes.Font.
Before setting it, the system defaults to Helvetica 12pt, with a line height of 13.8.
This line height seems accurate as shown by the image here:
However if I set the UIStringAttributes.Font…

jho
- 199
- 1
- 8
0
votes
3 answers
Text alignment won't work using AttributedString SwiftUI 3
I tried using the new AttributedString in SwiftUI 3
I want to change the alignment, but it won't work.
Any things else is working fine, for example I tried change color using attributedString it does work !. But I cannot do anything with…

Basel
- 550
- 8
- 21
-1
votes
1 answer
Deriving the strings corresponding to each attribute run in a Swift AttributedString
I want to be able to iterate through a (value-type) AttributedString in Swift constructed from markdown and build arrays of words, a separate array for each attribute type in the text.
For example, if the markdown is "bold moreBold italicText", the…

hkatz
- 951
- 11
- 21
-1
votes
1 answer
What Happened to NSAttributedString in Swift 5? Bold Doesnt work?
All the sample code i have comea cross with just does not work with bold tags anymore. This also include italic html tags.
I am using the code from hacking swift as string extension.
var htmlAttributedString: NSAttributedString? {
if let…

chitgoks
- 311
- 2
- 6
- 17