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

How to set up roundRect backgroundColor about characters correctly in NSTextView?

I want to set up roundRect backgroundColor for the important characters in NSTextView. The attribute is "tag". I override the func fillBackgroundRectArray(_:count:forCharacterRange:color:) of the **NSLayoutManager **. the code like below: …
Henry
  • 107
  • 1
  • 3
  • 10
2
votes
1 answer

iOS UITextView Unordered / Ordered List like Notes App

I'm trying to replicate Apple's Notes unordered list (bullet) but can't seem to get it work. I am currently using this string as attributed string which displays fine. "\u{2022}\texample bullet " However, when you try to select the string, it…
tzuer
  • 321
  • 4
  • 12
2
votes
1 answer

Text inside circle UILabel Swift 3

I know this has been asked a lot of times in SO but I couldn't find a reliable answer in Swift or even a good answer in general... I understand that this is possible with UITextField but UILabel is what I want to use.... I am asking if someone has…
George Asda
  • 2,119
  • 2
  • 28
  • 54
2
votes
0 answers

Is there a way to treat a word as a character in a UITextView?

I'm looking to treat a word as a character in a UITextView. I've previously got this working by detecting when a user has tried to delete a word, or if they've tried typing while in a word that we treat as a single character by seeing if the carat…
djdrzzy
  • 603
  • 4
  • 17
2
votes
0 answers

Text Kit not word-wrapping like Core Text with similar settings in UITextView

Using an exclusion path with a UITextView is not properly wrapping the words for the first and last line in the example shown (lower example). It does render properly using word-wrap with CoreText (top example image). Here is the code for the…
Jeshua Lacock
  • 5,730
  • 1
  • 28
  • 58
2
votes
0 answers

Find correct CGect of substring using TextKit and Touch Location

I have been working on wrapping my head around the TextKit work flow for Swift for a couple of days using some of the great questions and answers here among others. I'm trying to find the bounding rect of a substring found in a label, if the user…
wambambizzle
  • 105
  • 7
2
votes
1 answer

Drawing Text with Text Kit and *not* UITextView

I'm looking at TextKit and every tutorial I've come across gives me the same information: NSTextStorage holds your string and font information, NSLayoutManager manages layout and glyphs, and NSTextContainer specifies areas that the text should be…
Moshe
  • 57,511
  • 78
  • 272
  • 425
2
votes
1 answer

Swift 1.2 NSTextStorage removeAttribute with Range

I have a subclass of NSTextStorage and I'm trying to remove the foreground color of a paragraph the following way: var paragraphRange = self.string.paragraphRangeForRange( advance(self.string.startIndex,…
OscarVGG
  • 2,632
  • 2
  • 27
  • 34
2
votes
1 answer

NSTextAttachment Kerning

I'm trying to change the horizontal position of a NSTextAttachment image within a UITextView. I've tried setting [attributedString setAttributes:@{NSKernAttributeName:@(1.5)} range:NSMakeRange(0, 1)]; This simply makes the attachment disappear…
ethanyu
  • 143
  • 1
  • 6
2
votes
2 answers

How to animate text color change partially in UILabel with custom control?

I'm making a custom picker control and I'm facing a problem - I need to animate uilabels text color change partially. Here is the example: This is a default view of picker. When I click left or right side, the white selector will slide to that…
Dvole
  • 5,725
  • 10
  • 54
  • 87
2
votes
0 answers

Emoji Position in UITextView different in iOS 7 and iOS 8

I'm trying to get the lowest point y-coordinate of an Apple Emoji flag within my text view. I've tried a lot of approaches, so far this gives me the closest answer: textView.text = @"\U0001f1fa\U0001f1f8"; // US Flag textView.font = [UIFont…
ethanyu
  • 143
  • 1
  • 6
2
votes
1 answer

boundingRectForGlyphRange always returns rect for font size 12

I am trying to calculate the rects of individual glyphs using boundingRectForGlyphRange method. Everything works well except it always returns the rect as if the font size was 12. Event though I set it to 20 in attributed string. let font =…
Evgenii
  • 36,389
  • 27
  • 134
  • 170
2
votes
0 answers

Highlight text, like iBooks app for annotations (hopefully using TextKit)

I'm trying to build an iOS app, where from a piece text, the user can select and highlight words or phrases. Very similarly to iBooks app. I've been reading, and I've seen answers which say that iBooks uses Javascript to render highlight text. I'm…
Felipe Peña
  • 2,712
  • 4
  • 22
  • 41
2
votes
3 answers

UITextView with NSAttributedString and NSTextAttachment. How to show text?

I've create a UITextView that I've added to a UIView, this TextView should display an image at the top right or left corner wrapped by some text. Creating the TextView isn't the issue (obviously), I just can't wrap my head around the…
AlBirdie
  • 2,071
  • 1
  • 25
  • 45
2
votes
0 answers

iOS custom UITextView with vertical text

As I know Apple's TextKit not support NSTypesetter(which can set write direction top to bottom), but my language (Traditional mongolian) should be written top to bottom. So I want to customize the UITextView with subclassing and have done a simple…
user2644464
  • 101
  • 2