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

Saving and pasting an attributed string with a custom NSTextBlock

I am trying to create a custom NSTextBlock, much like the one Apple did at WWDC 18 (23 mins in). Full demo project here. Okay, so it works great when I'm editing and marking a paragraph with my paragraph style that has the text block attached.…
9
votes
5 answers

How do I make a part of a UILabel visually be a block quote?

How do I make a specific portion of a UILabel look like a blockquote, or have there be a vertical line on the left side of the text? Would TextKit come in here? If so, how? Mail.app does this (see the colored portions and the line on the side of…
Doug Smith
  • 29,668
  • 57
  • 204
  • 388
9
votes
1 answer

Example of NSTextContainer with non regular shape?

Hi I'm working with the new TextKit API for iOS7 and I'm trying to produce a UITextView with an irregular shape. So far I have in a view controller: -(void) loadView { self.view = [[UIView alloc] initWithFrame:CGRectMake(0,0,320,548)]; …
Ser Pounce
  • 14,196
  • 18
  • 84
  • 169
9
votes
1 answer

Exclusion paths on a UILabel's TextContainer

Is it possible to set exclusion paths on a UILabel? The apple documentation states that UILabel is now built upon TextKit but a UILabel does not seem to expose a textContainer property. I am looking to implement a tableview cell which includes…
bencallis
  • 3,478
  • 4
  • 32
  • 58
9
votes
1 answer

Using a CALayer to highlight text in a UITextView which spans multiple lines

This is a continuation of Getting CGRect for text in a UITextView for the purpose of highlighting with a CALayer. I'm having trouble with getting the correct rectangle for the ranges in each line fragment. NSString* searchString = @"Returns the…
Myron Slaw
  • 886
  • 9
  • 21
9
votes
5 answers

what to use instead of scrollRangeToVisible in iOS7 or TextKit

In previous versions of iOS, my UITextView will scroll to the bottom using [displayText scrollRangeToVisible:NSMakeRange(0,[displayText.text length])]; or CGFloat topCorrect = displayText.contentSize.height -[displayText…
Nelson Ko
  • 247
  • 4
  • 11
8
votes
1 answer

Rich TextView in SwiftUI

I'm trying to do a simple notes app in SwiftUI and I'd like to know if there's any library for having a simple rich text view that allows users to write in bold, italics, strikethrough, underline, etc. I've tried LEOTextView, but it is very buggy,…
amodrono
  • 1,900
  • 4
  • 24
  • 45
8
votes
2 answers

Calculate cell height for TextView with exclusion paths

If I have a TextView with exclusion paths in a UITableViewCell, how can I calculate the cell's height for a given string?
Ghar
  • 625
  • 1
  • 7
  • 19
7
votes
1 answer

How to define a custom NSUnderlineStyle

Looking at the documentation for NSLayoutManager, specifically the drawUnderlineForGlyphRange:underlineType:baselineOffset:lineFragmentRect:lineFragmentGlyphRange:containerOrigin: method, I noticed the following (emphasis mine): underlineVal The…
Arnold
  • 2,390
  • 1
  • 26
  • 45
7
votes
1 answer

Selecting a word and shows tooltip in iOS

I would like to implement the Medium iOS App like effect for tapping highlight and shows tooltip. I have been researching on Text Kit and some other stackoverflow questions have some thoughts on it, please also suggest what's the better…
Harry Ng
  • 1,070
  • 8
  • 20
7
votes
0 answers

Editable UITextView with multiple columns

I need to develop a text editor (UITextView) that will have multiple columns. I'm currently trying to accomplish this using Text Kit. Unfortunately, we can only use one TextContainer in UITextView (textContainer property). I've seen a lot of…
alexishacks
  • 233
  • 3
  • 10
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
7
votes
0 answers

How to replace the text storage of an NSLayoutManager

I'm trying to build a table view cell that has a UITextView. To reuse this table view cell, I set a new text storage to the layout manager. But adding the layout manager to the new text storage does not change the text storage of the text view. The…
Tobias Kräntzer
  • 1,694
  • 1
  • 13
  • 23
7
votes
3 answers

Customize underline pattern in NSAttributedString (iOS7+)

I'm trying to add a dotted underline style to an NSAttributedString (on iOS7+/TextKit). Of course, I tried the built-in NSUnderlinePatternDot: NSString *string = self.label.text; NSRange underlineRange = [string rangeOfString:@"consetetur sadipscing…
Daniel Rinser
  • 8,855
  • 4
  • 41
  • 39
7
votes
2 answers

NSTextAttachment custom view

Is it possible to display a custom view in the spot where an NSTextAttachment is to be displayed on iOS? I have custom text storage and layout manager subclasses, but I'm not sure where to put the code to actually add a subview. (The reason I want…
architectpianist
  • 2,562
  • 1
  • 19
  • 27
1 2
3
18 19