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

How can I replicate GitHub's app code block style in UITextView?

I am trying to create a markdown editor for fun and because I was interested in learning TextKit. I am working on iOS devices only, so I only have UIKit framework at my disposal, also I watched this WWDC18 video which explains some best practices to…
3
votes
0 answers

TextKit: How is the editor placeholder feature implemented in Xcode?

I took a deep dive into TextKit and wondered how the editor placeholders are implemented in the Xcode code editor: You can also try this yourself and type something along the lines of: <#Hello#>, which automatically turns into a placeholder. The…
Mark
  • 6,647
  • 1
  • 45
  • 88
3
votes
2 answers

How to display rounded gray background by tapping specific characters in UITextView?

I am trying to display text using UITextView. I added "See More" when displaying long texts. I would like to change the background color when tapping it. I set the background of NSAttributedString, but I can not set round corners and margins…
user9383160
3
votes
0 answers

How to properly draw underlines in NSLayoutManager

I have currently subclassed NSLayoutManager along with other classes in the UITextView architecture in order to implement my own Word Processor like UITextView. I am currently facing a problem when trying to layout underlines under ranges of glyphs…
AyBayBay
  • 1,726
  • 4
  • 18
  • 37
3
votes
1 answer

swift alternative for fontDescriptorWithSymbolicTraits ios 8 bug

I'm trying to create a Swift custom text editor (lite version) and got stuck on iOS 8 fontDescriptorWithSymbolicTraits bug, returning nil. Are there any Swift workarounds? I've created a small project sample here , you can download and run the…
el.severo
  • 2,202
  • 6
  • 31
  • 62
3
votes
3 answers

Adding UITextField inline UILabel (Fill in the blanks)

I am trying to achieve something like this for iOS in Objective C. The fill in the blanks(UITextField) should be inline, and should be able to have its own inputType. Also, each View is a type of cell.contentView of a UITableViewCell. My current…
Dheeraj Jami
  • 190
  • 2
  • 14
3
votes
0 answers

Supporting Drop Caps in Text Kit

I’m building an iOS reader app where I need to be able to highlight selections of text and optionally link notes with highlights. I’ve begun by using Text Kit (UITextView, NSAttributedString). I am targeting iOS 7, 8, and 9. My problem is that I…
davew
  • 1,255
  • 15
  • 27
3
votes
0 answers

NSAttributedString with image doesn't work in UITextField?

I'm inserting an image into an NSAttributedString with the following solution: https://stackoverflow.com/a/20930656 I've been able to get this working in a UITextView, but for some reason it doesn't work in a UITextField. Any ideas? Thanks
user339946
  • 5,961
  • 9
  • 52
  • 97
3
votes
1 answer

When creating a series of NSTextContainers, how do I specify container breaks based on the text content?

I'm creating a series of NSTextContainers to hold the text from an HTML resource. I am able to add the HTML to an attributed string, assign that to a NSTextStorage and NSLayoutManager, and create a series of NSTextContainers to hold all the text.…
user797892
  • 186
  • 1
  • 8
3
votes
1 answer

get text in NSTextContainer

I have a NSOrderedSet of paragraphs with NSString content. Looping through all, a large string is created and given NSTextStorage. But with that all the paragraphs are lost. The code below allows me to count the pages and present the content in…
Giwan
  • 1,564
  • 14
  • 17
3
votes
1 answer

Align text before a tab stop to the right, and after it to the left

I'm using Text Kit to layout some custom text in an app of mine, and I want to create nice-looking lists, with properly aligned enumerators. I need the text to look like so: The pink line is not part of the desired effect, but to emphasise how the…
obeattie
  • 3,264
  • 2
  • 31
  • 36
3
votes
0 answers

iOS7: CTLine does not honor NSBaselineOffsetAttributeName

In iOS7, using NSLayoutManager with an NSTextStorage with ranges that have NSBaselineOffsetAttributeName set with a positive or negative offset (for subscript and superscript) works - the resulting ranges are currently rendered with a vertical…
bright
  • 4,700
  • 1
  • 34
  • 59
3
votes
1 answer

UITextView text is loosing font size when i set an Attribute on NSTextStorage with NSUnderlineStyleAttributeName

In my App i have a UItextView and its input view has accessory view with couple of buttons on it. I am trying to change the text already being typed to underline text. Its working fine but its loosing the font and the font size after…
Ashutosh
  • 5,614
  • 13
  • 52
  • 84
3
votes
1 answer

Alternate backing store for NSTextStorage

Every example shows an NSMutableAttributedString as the "backing store" for keeping the text and attributes related to viewing/editing text. How can I use an alternate, such as std::string or maybe content from a database. Just as a test, I have…
PaulPerry
  • 906
  • 5
  • 14
3
votes
4 answers

NSLineSeparatorCharacter in iOS?

The String Programming Guide in the iOS Developer Library mentions "Line and Paragraph Separator Characters": NSParagraphSeparatorCharacter and NSLineSeparatorCharacter. But Xcode is not accepting them (iOS7 is the target): NSLog(@"This is%Con two…
user1459524
  • 3,613
  • 4
  • 19
  • 28