Questions tagged [nsparagraphstyle]

49 questions
30
votes
6 answers

UILabel: wrap and/or break inside word(s) with hyphen(s)

How do I set a UILabel lineBreakMode to break words and add hyphens to broken words? a label with a broken wo- rd should look like this
David Ben Ari
  • 2,259
  • 3
  • 21
  • 40
9
votes
4 answers

How do I limit NSTextView to 2 lines?

I'm trying to specify the number of lines for NSTextView. My designer is requesting 2 lines of text max. I've tried NSMutableParagraph style to add the ellipses truncation that I want, but with NSMutableParagraph I can only get NSTextView with 1…
8
votes
2 answers

NSAttributedString with image attachment and NSTextTab, text not aligned

I'm trying to have a UIlabel with an image and title on the left and a list of descriptions with bullets on the right. To do that I'm using NSAttributedString like this : NSMutableParagraphStyle *pStyle = [[NSMutableParagraphStyle alloc]…
Mosbah
  • 1,347
  • 1
  • 14
  • 28
8
votes
3 answers

Draw a line inside a UITextView - NSAttributedString

I wish to draw a customizable line inside a UITextView consisting of some text (using NSAttributedString) Here's what I tried NSString *unicodeStr = [NSString stringWithFormat:@"%C%C%C", 0x00A0, 0x0009, 0x00A0]; //nbsp, tab,…
lostInTransit
  • 70,519
  • 61
  • 198
  • 274
8
votes
2 answers

Adding NSMutableParagraphStyle lineSpacing cause text to not fit UILabel

I have created a normal UILabel and want to be able to add line spacing to the text which does into the UILabel. Although when I do this it affects the adjustsFontSizeToFitWidth and it is no longer fitted to the UILabel. Some code I have used: …
Henry Brown
  • 2,219
  • 8
  • 31
  • 48
8
votes
2 answers

Limit NSAttributedString number of lines

is there a way to limit number of lines in paragraph in NSAttributedString? Im appending two strings in NSAttributedString and i want them to be maximum 3 lines, the first string will be 1-2 lines , truncated if needed. and the second string should…
ItayAmza
  • 819
  • 9
  • 21
7
votes
2 answers

Modifying line spacing property in NSParagraphStyle causes cursor elongation

I have a subclassed UITableViewCell that contains a UITextView. I've added NSParagraphStyle as an attribute to the string in a subclassed NSTextStorage. In the following code, I've increased the space between each row in the UITextView. swift let…
akamas
  • 91
  • 5
5
votes
2 answers

UILabel - How to add space between lines in Swift 3

I've UILabel with paragraphic information (multiline text) and I want add some spaces between lines, similar to this image. Please help me to do it. I've tried to checkout all documentation of apple developer regarding Label and line spacing but…
user7620770
5
votes
0 answers

NSParagraphStyle how to set maximum number of lines per paragraph

I am trying to achieve something like this (with the grey text always at the bottom of the textview): but when I set the line break mode to NSLineBreakByTruncatingTail it only allows 1 line of text per paragraph like this: I would like to truncate…
Halpo
  • 2,982
  • 3
  • 25
  • 54
5
votes
1 answer

How can I vertically center a line in an NSAttributedString with different fonts?

I have a NSAttributedString which is a "table" using NSTextTab stops where the first column is the KEY and the second column is the value Like this: | **KEY 1**|value1| |**KEY TWO**|value2| The font for the KEYS is different size/weight + it is…
4
votes
1 answer

Fix cursor size for modified paragraph spacing in UITextView

I have a custom, editable UITextView and I modified the paragraph spacing like so: func layoutManager(_ layoutManager: NSLayoutManager, paragraphSpacingBeforeGlyphAt glyphIndex: Int, withProposedLineFragmentRect rect: CGRect) -> CGFloat { return…
Adam Bardon
  • 3,829
  • 7
  • 38
  • 73
4
votes
1 answer

NSTextView is too slow to update while changing the attributes with different NSParagraphStyles

I want NSTextView object to react to Tab key hit by changing NSParagraphStyle spacing. And it does but EXTREMELY slow!!! In fact if I do this changes too quick (hit Tab key too fast), I eventually got glitches that sometimes even lead to crash.…
Vitalii Vashchenko
  • 1,777
  • 1
  • 13
  • 23
4
votes
1 answer

How to set alignment for WKInterface Label using setAttributedText

I'm trying to set alignment for WKInterfaceLabel using setAttributedText function. Here is my code: var paragraphStyle = NSParagraphStyle.defaultParagraphStyle() paragraphStyle.alignment = NSTextAlignment.Center var attributedDictonary =…
4
votes
0 answers

NSAttributedString: Spacing between bullet and text

I'm creating textviews with an html document that I'm loading with [[NSAttributedString alloc] initWithFileURL: There are many unordered lists (
    ) in the HTML document. I cannot find a way to reduce the space between bullets in an unordered list…
4
votes
0 answers

NSTextAlignmentJustified exception with arabic string

I am using Arabic string and I want to justify it inside UITextView. I am retrieving incoming attributingString in the textView and enumerate the NSParagraphStyleAttributeName to edit it like this : NSMutableAttributedString * mstring =…
1
2 3 4