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
2
votes
0 answers

iOS7 glyphRangeForTextContainer - select all glyphs / all text range in a UITextView

I am trying to achieve linespacing when typing into a UITextView. I have this function which seems to render the linespacing only for all the characters upto the cursor position when you click inside the UITextView. How do I write the function to…
Wael
  • 489
  • 6
  • 19
2
votes
1 answer

Using TextKit with storyboards

I have a UITextView in a storyboard with a UINavigationController, which looks like this: It has an autolayout constraint at the top to prevent the uppermost text from being hidden beneath the navigation bar and a constraint to the left, right and…
mrappleton
  • 372
  • 3
  • 10
2
votes
1 answer

UILabel Bold / Highlight All occurrences SubString

I have multiple UILabels within a Custom Table cell. These labels contain varied text or varied length. As it stands i have UILabel Subclassed allowing me to implement these methods - (void)boldRange:(NSRange)range { if (![self…
scottevans93
  • 1,119
  • 1
  • 9
  • 25
2
votes
1 answer

Redrawing UITextView selection after changing paragraph style

As a preliminary stage to an app I want to make, I've set up a simple test example of indenting the paragraphs in a UITextView. It basically sets up an NSTextStorage with some text and puts it in a text view. When the user taps an indent button, I…
architectpianist
  • 2,562
  • 1
  • 19
  • 27
2
votes
3 answers

Text Kit with SKLabelNode

It seem not possible to use text kit, attributed string and layout manager with Sprit Kit SKLabelNode. I wonder how Sprite Kit game display Long text which need to break into multiple line and Attributed String?
Elliot Yap
  • 1,076
  • 1
  • 12
  • 20
2
votes
1 answer

What is the simplest way to set the line height of a UIlabel using TextKit in iOS 7?

I'm assuming I can do this concisely with TextKit. I don't need backwards compatibility. I don't want to destroy any existing attributes on any NSAttributedString instances involved. I don't necessarily mind subclassing UILabel if I can get a…
Michael Forrest
  • 3,461
  • 4
  • 22
  • 35
2
votes
2 answers

How do I eliminate leading whitespace when computing word boundaries using boundingRectForGlyphRange in NSLayoutManager

I am decomposing a multiline string into word boundaries on iOS. My solution centers around the boundingRectForGlyphRange method of NSLayoutManager. It ALMOST works, except that the rect for each word is a few pixels off to the right. In other words…
Rolf Hendriks
  • 411
  • 4
  • 8
2
votes
0 answers

Parsing NSAttributedString to HTML on iOS 7

I have an NSAttributedString (coming from HTML) that I set for a UITextView. - (void)setHtml:(NSString *)html { NSData *htmlData = [html dataUsingEncoding:NSUTF8StringEncoding]; // Create the HTML string NSDictionary *importParams =…
Jesse Naugher
  • 9,780
  • 1
  • 41
  • 56
2
votes
2 answers

iOS 7 using an HTML string as an NSAttributedString AND setting the font?

I have a UITextView in which I'm trying to display some attributed text which comes in the form of HTML. It uses things like inline bolding and italicizing. The client now wants the font on this to change. However, whenever I change the font, it…
s73v3r
  • 1,751
  • 2
  • 22
  • 48
2
votes
3 answers

How to clear a UITextView with a custom NSTextStorage? [iOS7 only]

I'm currently trying to create an SMS-like screen, where the user can write some text and send it to other users. Everything goes as expected until I try to clear my text view and encounters a crash. I've been trying to find a way around this issue,…
Julien
  • 21
  • 1
  • 4
2
votes
0 answers

textkit custom text attribute draws big rect when it spans multiple lines

I am basically creating a custom attribute to draw a rounded rectangle in my text subclassing NSLayoutManager with drawGlyphsForGlyphRange method below. Below works like a charm with ranges that spans one line. However, when the range of text spans…
ilteris
  • 457
  • 1
  • 7
  • 21
2
votes
1 answer

Animate NSLayoutManager drawing

I have an NSLayoutManager which is drawing text using the following code: [[self textLayoutManager] drawGlyphsForGlyphRange: NSMakeRange(0, [[self text] length]) atPoint: textFrame.origin]; in my view's…
Patrick Perini
  • 22,555
  • 12
  • 59
  • 88
2
votes
1 answer

TextKit doesn't layout text after a wide exclusion path

I took the TextKit example project from objc.io #5 http://www.objc.io/issue-5/getting-to-know-textkit.html and modified the width and the form of exclusion path in Text Interaction Demo. I made the exclusion path width more then its container width.…
Alexey
  • 440
  • 3
  • 12
2
votes
0 answers

Autolayout of UILabel failing when no single line touches left edge

I have an NSAttributedString in a UILabel that looks like this: | Indented line | Where the |'s mark the UILabel max preferred width. The indented line has been indented using a paragraph style attribute: NSMutableParagraphStyle *style…
tarmes
  • 15,366
  • 10
  • 53
  • 87
2
votes
2 answers

Rendering text in uppercase without changing the backing string? (iOS7 & Text Kit)

My application targets iOS 7 only. I have a UITextView presenting an NSAttributedString. The string represents a document, each paragraph has a number of attributes set on it for styling. Some paragraphs need to be rendered in ALL CAPS, however, the…
James J
  • 6,428
  • 6
  • 35
  • 45