Questions tagged [nsmutableattributedstring]

357 questions
7
votes
6 answers

NSMutableAttributedString's attribute NSStrikethroughStyleAttributeName doesn't work correctly in iOS8

I have a mutable attributed string without NSStrikethroughStyleAttributeName attribute like this: NSMutableAttributedString *str1 = [[NSMutableAttributedString alloc] initWithString:@"aaaa" attributes:@{NSStrikethroughStyleAttributeName:[NSNumber…
7
votes
2 answers

NSAttributedString on multiline UILabel cutting off first line

I've looked at ~10 questions on SO and am still coming up short. I have a multiline UILabel (created in Interface Builder, numberOfLines set to 0) which renders normally like this: I want to be underline "Terms of Service" and "Privacy Policy", so…
7
votes
1 answer

NSMutableAttributedString vertical alignment

I have a ellipse path for text. For fill path I used NSMutableAttributedString: UIFont *font = [UIFont fontWithName:@"font name" size:15]; NSMutableParagraphStyle *mutParaStyle=[[NSMutableParagraphStyle alloc] init]; [mutParaStyle…
bpa
  • 183
  • 1
  • 12
7
votes
1 answer

Apply rich text format on selected text of UITextView in iOS

I am creating an app in which i have to implement functionality like this: 1) Write into textview 2) Select text from textview 3) Allow user to apply bold,italic and underline functionality on selected text. I have started implementing it using…
Shah Paneri
  • 729
  • 7
  • 28
6
votes
0 answers

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 bold and italics attributes to…
6
votes
2 answers

Swift - check if attributed text is empty

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() } set { …
DevB1
  • 1,235
  • 3
  • 17
  • 43
6
votes
0 answers

SKLabelNode + NSMutableAttributedString = no shadow

let paragraph = NSMutableParagraphStyle() paragraph.alignment = NSTextAlignment.right paragraph.tailIndent = -3 let shadow = NSShadow() shadow.shadowBlurRadius = 5 shadow.shadowColor = UIColor.gray shadow.shadowOffset =…
6
votes
3 answers

Attributed string in tableviewcell not showing bold text until the cell is dequeued and reloaded

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 attribute is not being displayed until the cell is…
Cen92
  • 171
  • 1
  • 13
6
votes
3 answers

Uneditable prefix inside a UITextField using Swift

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 an IBOutlet to it, named usernameField, then using…
Aluminum
  • 2,932
  • 5
  • 35
  • 63
6
votes
1 answer

NSMutableAttributedString will not display attribute that begins at nonzero index

UPDATE: I created a really simple standalone project to demonstrate the bug. If anyone would like to pull same and see if they can spot where I've gone wrong, I'd sure appreciate it. There's not much code to look through. Public repo…
Reid
  • 1,109
  • 1
  • 12
  • 27
5
votes
1 answer

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() imageAttachment.image = UIImage(named: "icon") let imageString…
Rio
  • 73
  • 8
5
votes
2 answers

UITextView attributed text not working when using custom font

I'm using UITextView and I'm setting its font and attributed text by code. Case 1: Custom-font - YES , attribtued text- NO The textView text is displayed in custom font. I want the attribtued text with custom font i.e Message : in this case shold…
Teja Nandamuri
  • 11,045
  • 6
  • 57
  • 109
5
votes
2 answers

Set label font with bold and italic

I'm trying to set a specific part of my label to bold and italic with NSMutableAttributedString, but I can only get one or the other. The font that I'm using is Clear Sans. Setting the entire label's font on the storyboard to Bold Italic works fine,…
Cody Harness
  • 1,116
  • 3
  • 18
  • 37
5
votes
1 answer

Add NSAttributedString to UIBarButtonItem

I'm attempting to set an attributed string on my back bar button item. This is my first attempt at attributed strings. Here is the code: self.navigationItem.hidesBackButton = true let barButtonBackStr = "< Back" var…
Juio
  • 143
  • 1
  • 13
5
votes
1 answer

End of NSAttributedString with emojis left unformatted

The end of my NSAttributedString with emojis in the contents is not being formatted. I'm trying to format the entire string (set the text color to white in this example, for simplification), but some of the text stays unformatted when put in a…
Jojodmo
  • 23,357
  • 13
  • 65
  • 107
1 2
3
23 24