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
5
votes
1 answer

Dynamic type notification is not getting triggered

I'm currently developing in Swift and have run into a problem with the dynamic typing. I have set this code import Foundation import UIKit class ExerciseController :UIViewController, UITableViewDataSource, UITableViewDelegate { @IBOutlet var…
AJ_1310
  • 3,303
  • 3
  • 19
  • 26
5
votes
2 answers

Getting CGRect for text in a UITextView for the purpose of highlighting with a CALayer

I am trying to draw a transparent CALayer in a UITextView in order to highlight matched text in a search. I've figured out the correct way to do this, but still haven't found the correct coordinates. I need to find the origin of the text container.…
Myron Slaw
  • 886
  • 9
  • 21
5
votes
1 answer

Newlines in iOS 7 UITextView breaking Text Kit exclusion zone wrapping

I'm working with Text Kit in iOS 7 and I'm finding a lot of oddities around NSTextContainer exclusion zones. I've got two views: a UITextView and a simple draggable UIView; as the UIView moves, I create a bezier path from the UIView's frame…
Rob
  • 25,984
  • 32
  • 109
  • 155
4
votes
1 answer

Aligning glyphs to the top of a UITextView after sizeToFit

The app I'm working on supports hundreds of different fonts. Some of these fonts, particularly the script fonts, have significant ascenders and descenders. When sizeToFit() is called on a UITextView with some of these fonts, I end up with…
user2393462435
  • 2,652
  • 5
  • 37
  • 45
4
votes
1 answer

Subclassing NSTextStorage breaks list editing

I have a basic Mac app with a standard NSTextView. I'm trying to implement and use a subclass of NSTextStorage, but even a very basic implementation breaks list editing behavior: I add a bulleted list with two items I copy & paste that list further…
Mark
  • 6,647
  • 1
  • 45
  • 88
4
votes
0 answers

On a UITextView loaded from NIB, how can I customize the layout manager?

I know that there is an initializer for UITextView that takes a custom container which in turn can have a custom layout manager attached. But I would prefer to setup my text view from NIB instead. How would I - most elegantly - customize the layout…
Cocoanetics
  • 8,171
  • 2
  • 30
  • 57
4
votes
1 answer

What does font size really mean in ios?

Seems font size doesn't determine anything. Here is two line, one use font zapfino, another use system font. They both has size 30, but the line height or other font metrics is really different. This pic is draw with YYLabel which use coretext…
Karl
  • 665
  • 4
  • 19
4
votes
0 answers

Custom truncation UITextView

I have a UITextView with strings that could be any length. The size of the UITextView is fixed and if the string doesn't fit it needs to be truncated. I'm currently setting self.titleTextView.textContainer.lineBreakMode =…
James
  • 41
  • 3
4
votes
2 answers

UIPageViewController/TextKit Reflowing Text on paging

I'm working on a multi-page reading application backed by TextKit, based off of the "Advanced Text Layouts and Effects with Text Kit" session from WWDC 2013 (but with some code reconstructed from incomplete example). The basic structure is you…
Aaron
  • 173
  • 2
  • 13
4
votes
0 answers

UITextView: "Link-ification" / dataDetector process is slow

I've got a UITextView, wired with a TextKit stack: custom NSTextStorage subclass, and standard NSLayoutManager + NSTextContainer instances. While editing a large document (~80kb, ~200 URL Links), our app's main thread freeze during the…
4
votes
2 answers

UITextView - Highlight text with NSBackgroundColor - exclude line breaks

I have a working feature with text highlighting, the problem is that it also highlights line break. See the image: Below is a function I use for highlighting: -(void)setHighlight{ //set highlighted __block BOOL textIsHighlited…
adam
  • 807
  • 3
  • 11
  • 17
4
votes
1 answer

Underline text - line thickness in crossing ranges with different font sizes

I am working with the attributes of textStorage of UITextView. I have the string and an array of the objects of my class TextFormattingElement. An instance of this class consists of NSRange (on which this element has to be applied in text) and some…
xexe
  • 346
  • 1
  • 9
4
votes
4 answers

Replace the truncation ellipsis of UILabel in iOS 7

How can I replace the truncation ellipsis ("…") of a UILabel in iOS 7 with another attributed character? For example, with a colored ">". I was hoping Text Kit's NSLayoutManager would make this possible, but it appears UILabel doesn't make it public…
hpique
  • 119,096
  • 131
  • 338
  • 476
4
votes
1 answer

attributed text not working on TableView Cell

trying to use a different font and font size on TabelViewCell but its not working. Here is what I tried: cell.textLabel.attributedText = [infoCells objectAtIndex:indexPath.row]; This code makes the app crash Then i tried this: cell.textLabel.text…
user1951876
  • 294
  • 2
  • 5
  • 16
4
votes
1 answer

characterIndexForPoint returning different results for same parameters

I have a UITextView which is hooked up to a pan gesture recognizer. When I drag my finger over the text view, I use the characterIndexForPoint method to figure out which character my finger is over & then highlight the text at that point. In some…
Epaga
  • 38,231
  • 58
  • 157
  • 245