360 questions
0
votes
0
answers
147
views
Object cannot be nil (key: NSFont) at NSMutableAttributedString in UILabel on iOS 17-18
I am encountering a runtime error in my iOS application when trying to set an NSAttributedString to a UILabel. The crash message on Firebase Crashlytics is:
*** -[__NSDictionaryM setObject:forKey:]: ...
1
vote
1
answer
87
views
Is there an option to apply single strikethrough line for NSMutableAttributedString with different fonts?
I have an NSAttributedString with two different font sizes for displaying currency in pennys.
I need to apply strikethrough to all strings, but not to break line of strikethrough.
How can I draw a ...
15
votes
1
answer
2k
views
Using `NSTextAttachment` in SwiftUI `Text`
Does SwiftUI Text not work with NSTextAttachment? I have this AttributedString:
var attributedString: AttributedString {
var sampleAttributedString = AttributedString(sampleText)
// Apply some ...
8
votes
2
answers
4k
views
Issue with applying paragraph style in SwiftUI
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 ...
1
vote
0
answers
57
views
ScrollView is not smooth when loading HTML content into Label CollectionViewCell
i am making status app where all status are being fetched from my Wordpress Website , all working fine but i found some problem when i fetch html content and showing it in cells using UILabel. when i ...
0
votes
1
answer
172
views
Conflicting attributes on NSMutableAttributedString: .foregroundColor vs .strokeWidth
I have created a var with default text attributes for an NSMutableAttributedString:
static var textFieldDefaultTextAttributes: [NSAttributedString.Key: Any] = [
.font: UIFont(name: "Impact"...
0
votes
4
answers
1k
views
Enable orphan words feature for NSMutableAttributedString
The default behavior for UILabel is that it prevents orphan words to appear solely on a separate line. ie: if word wrapping happen to keep 1 word alone at the last line. iOS will prevent that by ...
1
vote
1
answer
1k
views
SwiftUI get NSViewRepresentable to automatically redraw
I have introduced a styled NSViewRepresentable text field on to my layout in order to use an attributed Text Editor field. I want to influence the content of this text field through some buttons.
I ...
0
votes
0
answers
65
views
I don't know how to set text inset into uilabel from uiimage in swift
I was written to code using NSMutableAttributedString() with UIImage() and String.
extension UILabel {
func attachImageLabel(string: String, image: UIImage?) {
let attachment = ...
0
votes
2
answers
306
views
Swift: NSMutableAttributedString generated from PDF. Can it be parsed into a Dictionary?
I have several large PDF docs (70-200, pages each). The PDFs themselves are generated from HTML pages (I can't get the source code of the HTML pages which is why I am working with the PDFs). Anyway, ...
0
votes
1
answer
863
views
How to push view controller on click of HyperLink in Swift 5
Hi I have to push a viewController on click of HyperLink. I have NSMutableAttributedString text. that attributed text have two hyperlink examples GoToHomeScreen and aboutUs both are hyperLink on ...
0
votes
0
answers
289
views
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 ...
1
vote
0
answers
233
views
NSAttributedString keeps its attribute after its range in TextView using Swift
I am using attributed text string in Swift inside a textview, once I add a link attribute to the textview, whatever user writes after that link attribute it will be still as a link attribute and not a ...
0
votes
1
answer
251
views
Add font to NSMutableAttributedString where .font attribute is missing
I want to apply a specific font to an NSMutableAttributedString where no .font attribute is applied. How could I achieve that?
I tried enumerating the attributes that contain a font and extracting the ...
2
votes
2
answers
2k
views
Save a UITextView attributed string to file in SwiftUI
I need to work with attributed strings (NSMutableAttributedString) in SwiftUI to make a simple rich-text editor, and as you might already know, attributed strings are not natively supported in SwiftUI....
1
vote
1
answer
191
views
How to check if an NSMutableAttributedString font size is smaller/greater than some value?
I try to make an if block by checking if an NSMutableAttributedString font size is smaller/greater than some value. I couldn't find an explanation about this. Code sample is as follows:
if textView....
1
vote
4
answers
2k
views
Why strikethrough is not working in iOS 14
I have one UILabel which shows strikethrough text (e.g. text). It was working fine till iOS 13. In iOS 14, that strikethrough line is not showing, i.e. instead of 'text', it is coming as 'text'. This ...
0
votes
0
answers
452
views
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 ...
0
votes
1
answer
823
views
How to Align Text with NSAttributedString in swift
I am looking for align Text in NSAttributedString. It should be on same indent(List of string on same Column).
Output:
I have used below code
func setAttributedText() {
let ...
0
votes
1
answer
415
views
Can we restrict the width of a NSMutableAttributedString?
I have a string Ex: Arya said "We must find a solution" yesterday. Here I want to restrict the width of the text in bold ("We must find a solution") to 100, but others must not be ...
-1
votes
1
answer
342
views
NSAttributedString won't add attributes to a string. (Swift 5)
I'm trying to colour occurrences of a string in a string using the below:
let text = "R09/27 R13/51 R22/08 R11/11"
let attributed = text.color2(redText: ["R09/27", "R11/11"], orangeText: ["R13/51"])
...
3
votes
1
answer
399
views
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 ...
0
votes
1
answer
64
views
NSMutableAttributedString Using NSLinkAttributedName
Getting this from NSMutableAttributedString using the NSLinkAttributeName attribute.
Using a html file for the link name.
How to make the text area bigger.
-(NSMutableAttributedString *)...
0
votes
1
answer
114
views
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....
6
votes
2
answers
2k
views
Recognise an image tap in attributed String displayed in a label
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()
...