Questions tagged [textkit]

Text Kit is, collectively, a set of classes and protocols in iOS 7's UIKit framework that provide high-quality typographical services.

Text Kit, introduced in iOS 7, is a set of classes and protocols providing high quality typographical services including text layout, storage and display. It also enables direct control of typographical features such as kerning, ligatures, line break behaviour and justification. Text-related UIKit classes in iOS 7 - namely UITextView, UITextField and UILabel - are based on the Text Kit layout engine.

Allowing fine-grained control of fonts and styles through a mechanism Apple calls "Dynamic Type", Text Kit brings a much more refined an detailed system for text-handling to iOS.

272 questions
15
votes
1 answer

Confused by NSStringDrawingOptions item meaning

iOS7 and later, we can use - (void)drawWithRect:(CGRect)rect options:(NSStringDrawingOptions)options attributes:(NSDictionary *)attributes context:(NSStringDrawingContext *)context to calculate the string size, but I'm confused with the comments on…
yuyeqingshan
  • 381
  • 3
  • 13
14
votes
2 answers

Control spacing around custom text attributes in NSLayoutManager

I’ve got a custom NSLayoutManager subclass I’m using to draw pill-shaped tokens. I draw these tokens for substrings with a custom attribute (TokenAttribute). I can draw no problem. However, I need to add a little bit of “padding” around the ranges…
jbrennan
  • 11,943
  • 14
  • 73
  • 115
14
votes
1 answer

Creating animated text effects using NSLayoutManager?

In session 220 (Advanced Text Layouts and Effects with Text Kit) of WWDC 2013 they specifically say NSLayoutManager can be used in conjunction with NSTextStorage and NSTextContainer to create advanced text animations. They don't say how. I want to…
Rasto
  • 17,204
  • 47
  • 154
  • 245
14
votes
4 answers

How to fit text in a circle in UILabel

I'd like to flow the text in UILabel into a circle (instead of rect). I did some experiments with NSLayoutManager, NSTextContainer and NSTextStorage but it does not seem to work. The example below is supposed to flow the text into a smaller rect of…
pkuhar
  • 581
  • 6
  • 17
14
votes
2 answers

UITextView textContainerInset not respecting bottom inset value

I have a UIView displaying an NSAttributedString. It's set up to resize to fit its contents. I'd like to create some padding between the text and the view, however it's not quite working. If I do this... view.textContainerInset = UIEdgeInsetsMake(0,…
tarmes
  • 15,366
  • 10
  • 53
  • 87
14
votes
4 answers

How to obtain adjusted font size from UILabel when adjustsFontSizeToFitWidth is YES in iOS 7?

I have a label that is set to adjustsFontSizeToFitWidth = YES and I need to get the actual displayed font size. Now iOS 7 deprecated all methods that worked previously and all questions on SO suggest using these deprecated methods. I will make this…
openfrog
  • 40,201
  • 65
  • 225
  • 373
13
votes
2 answers

Interpolating UITextFields with UITextView using Text Kit?

I'm working on a text view that replaces placeholders with UITextFields. I pass it an object (a struct or a dictionary) with text containing multiple instances of a placeholder token. The dictionary also contains an array of fields that we want to…
Moshe
  • 57,511
  • 78
  • 272
  • 425
13
votes
0 answers

Replace NSTextContainer of UITextView when loading from XIB/Storyboard

I've made a custom subclass of NSTextStorage, which processes text as I need it to be processed. To use this on a text view I need to create a NSTextContainer and a NSLayoutManager, and then assign the container to the UITextView. This works…
Dominik Hadl
  • 3,609
  • 3
  • 24
  • 58
12
votes
2 answers

Hide Markdown Characters with NSLayoutManager in Swift

I am working on a rich text editor in a Mac app that uses Markdown syntax. I use NSTextStorage to watch for matches in Markdown syntax, then apply styles to the NSAttributedString in real time like this: At this point, I'm already in way over my…
Clifton Labrum
  • 13,053
  • 9
  • 65
  • 128
12
votes
1 answer

Get line information from UITextView and NSLayoutManager

In order to support the UIAccessibilityReadingContent protocol, I need my UITextView to answer me questions about its lines. These are the methods of the protocol that I need to implement: accessibilityLineNumberForPoint: <- Provided a coordinate,…
Mikkel Selsøe
  • 1,171
  • 1
  • 11
  • 23
11
votes
5 answers

NSAttributedString reporting incorrect sizes for UITextView sizeThatFits and boundingRectWithSize with correct options set

I have an NSAttributedString that is reporting a boundingRectWithSize (and by extension a UITextView which improperly calculates its sizeThatFits) when the font size is decreased from the font size that was used to create it. It doesn't happen on…
Austin Fitzpatrick
  • 7,243
  • 3
  • 25
  • 22
11
votes
1 answer

Bulletpoint spacing and linebreak start position with NSHTMLTextDocumentType

WIth iOS 7 came NSHTMLTextDocumentType, which Im using the code below to parse html and show it in a UITextView. It works perfectly, except with bullet points. How can I both change the spacing on each side of the bulletpoints(the space between the…
AlexanderN
  • 2,610
  • 1
  • 26
  • 42
10
votes
2 answers

NSTextContainer exclusionPaths freezes app and uses 99% CPU on iOS 7.1 - workaround?

I'm trying to exclude a square in a UITextView using NSTextContainer's excludePaths, like so: NSTextStorage* textStorage = [[NSTextStorage alloc] initWithAttributedString:attributedString]; NSLayoutManager *layoutManager = [NSLayoutManager…
René
  • 513
  • 3
  • 16
10
votes
4 answers

iOS Drawing text in the centre of shapes

I'm trying to draw text in the centre of shapes in iOS, an example would be Microsoft Office's insert shape see: https://www.dropbox.com/s/cgqyyuvy6hcv5g8/Screenshot%202014-01-21%2013.48.17.png I have an array of coordinates that are used to form…
Danielle
  • 181
  • 1
  • 3
  • 13
10
votes
2 answers

iOS 5/6 vs iOS 7 multiline label line spacing

I ran my app under iOS 7 and discovered that multiline labels (non-attributed, plain text) render with a small line spacing. Anyone knows what to do it with iOS 5 compatibility? iOS 5/6 iOS 7
efpies
  • 3,625
  • 6
  • 34
  • 45
1
2
3
18 19