Questions tagged [nsmutableattributedstring]

357 questions
0
votes
1 answer

Center text vertically in line of NSMutableAttributedString

I'm using NSMutableAttributedString to setup text style. When I set .minimumLineHeight, it centre text in line to the bottom of line. I would like to customise somehow this alignment to centre text in line vertically. let paragraphStyle =…
0
votes
1 answer

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", size: 32)!, .tracking: 2, .paragraphStyle:…
0
votes
3 answers

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 sending a word from the line before it, having two…
hasan
  • 23,815
  • 10
  • 63
  • 101
0
votes
1 answer

NSAttributedString change font size

I have an NSAttributedString which may have multiple subranges with different font styles and other attributes. How do I modify the size of font for the whole attributed string? Setting a font size of 20 should set pointSize of all fonts in the…
0
votes
1 answer

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 can change the styled attributes of the field, but…
iphaaw
  • 6,764
  • 11
  • 58
  • 83
0
votes
0 answers

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 = NSTextAttachment() attachment.image = image …
Tae Hun Yu
  • 39
  • 7
0
votes
2 answers

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, what I want to do is parse the PDF into separate…
PruitIgoe
  • 6,166
  • 16
  • 70
  • 137
0
votes
1 answer

How to apply Atrributed String different spacing between lines in swift

I want to apply spacing between first two lines in attributed string and third line should look like paragraph. Expected output : Expected output screenshot Current Implemenation: Current implementaion screenshot Here is the code tried by me. …
0
votes
1 answer

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 click of aboutUs need to open a link which is working…
0
votes
1 answer

Detect clicked mutable attributed string

I have this code to write a paragraph like book with numbering for each sentence , the problem I'm facing is i can't find how to color one sentence when the user clicks in any word from it import UIKit let descender: CGFloat =…
sheko
  • 516
  • 4
  • 15
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
1 answer

NSAttributedString ignores properties inside html tag

Word "TM" needs to be font-size 6px. let newText = "My new trade mark is MELLONTM Corporation" What I do, I convert it to AttributedString: let htmlToNSAttributedString = NSAttributedString(data: self, options:…
0
votes
1 answer

Cocoa: how to unarchive a NSMutableAttributedString with archived attributes?

I try to unarchive an archived NSMutableAttributedString in a macos-app, written in swift. I get back the text but without any attributes. The attributes are in the exported serialisation but it is ignored by NSMutableAttributedString(coder:…
0
votes
1 answer

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 ranges but I am kind of lost to the complexity…
0
votes
1 answer

NSMutableAttributedString text go down when reaches right anchor

I am trying to have a NSMutableAttributedString return multiple lines when the text reaches the width. I thought I could use numberOfLines but that's only accessible with UILabel? The text "Community Guidelines" and "Terms & Conditions" ideally…