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
1
vote
3 answers

Make selected string of text view Bold, Italic, Underline like native "Notes" app of iOS

Is there any help to make selected string of text view Bold, Italic, Underline like native "Notes" app of iOS. Please give me helpful links. I am tired of searching for the whole day. Many Thanks. I have attached my code, to make attributed string…
Adeel Ishaq
  • 101
  • 1
  • 10
1
vote
1 answer

Why does the second text block have so much higher line height than the first despite NSAttributedString disagreeing?

I'm given one NSAttributedString with two parts of text in it, the first is just a plain body of text, shown below, and after that is a sample block of code, also shown below (added a divider to more easily show). As you can see, the block of code…
1
vote
1 answer

Highlighting words with TextKit selecting the wrong occurrence of repeated words

I'm actually developing a Quran application in which I'm using TextKit to highlight verses and change their color. Everything is going great but I have a little problem with words that appear multiple times. First of all, my code is: import…
1
vote
1 answer

SKLabel avoid, use TextKit instead then create SKTexture?

Staying in SpriteKit, is it possible to create more "artistic" text with the vastly greater control TextKit provides, and then (somehow) convert these strings to images so they can be used as SKSpriteNodes? I ask because I'd like to do some more…
Confused
  • 6,048
  • 6
  • 34
  • 75
1
vote
1 answer

Custom NSTextStorage: emoji don't show up by default

I'm having a trouble with emoji in a custom NSTextStorage subclass. The class does not store any attributes passed to it. Instead, it generates its own: override func attributesAtIndex(location: Int, effectiveRange range: NSRangePointer) -> [String…
Archagon
  • 2,470
  • 2
  • 25
  • 38
1
vote
1 answer

NSForegroundColorAttributeName for UILabel using NSAttributedString

I have NSAttributed string with links in it and I want to load it inside UILabel. I works fine, however all links are blue Color. let string = NSMutableAttributedString(attributedString:…
Andrius Steponavičius
  • 8,074
  • 3
  • 22
  • 25
1
vote
2 answers

Vertically centering text in an irregularly shaped UITextView

I'm working on rendering text in the center of a circular or oval shaped region. Ideally, I'd like to center the text vertically and horizontally, but have it flow naturally at the boundaries of the region. I've found an approach using a UITextView…
duncanm
  • 796
  • 1
  • 6
  • 13
1
vote
3 answers

How to color text in UITextView

I've got four buttons on the view controller and a text view. These five buttons has colors, for example red, yellow, green, blue and black. When the user started to type without pressing those buttons the color of the text view being typed should…
Ankahathara
  • 2,866
  • 2
  • 20
  • 26
1
vote
1 answer

Cannot convert value of type 'UInt32!' to expected argument type 'UIFontDescriptorSymbolicTraits'

I´m still trying to convert TextKit from Objective-C to Swift. It drives me (and you ?) crazy :-( After fixing some problems, now i´m having trouble with the bold (and italic) font: func addOrRemoveFontTraitWithName(traitName: String, andValue…
Ulli H
  • 1,748
  • 1
  • 19
  • 32
1
vote
0 answers

Get Text from UILabel when it's Tapped using TextKit

I want to get the word when the UILabel is Tapped. I've tried using it with the TextKit. This is What I did: Assigned my label (attLabel) an attributed string: "Rachel has requested to join the Group". Also, I've added a tap gesture on the…
Bhavuk Jain
  • 2,167
  • 1
  • 15
  • 23
1
vote
0 answers

Multiple NSTextContainers do not work properly with UIPageViewController

I have a long text (multiple screen pages) stored in an NSTextStorage. I instantiate an NSLayoutManager() and add the textStorage to it. Then I keep adding NSTextContainers of specific size until I use up the whole text. The containers are also…
Jacklin Heirdom
  • 131
  • 1
  • 1
  • 11
1
vote
2 answers

Font Descriptors and Symbolic Traits

UIFontDescriptor *bodyFontDescriptor = [UIFontDescriptor preferredFontDescriptorWithTextStyle:UIFontTextStyleBody]; UIFontDescriptor *italicBoldDescriptor = [bodyFontDescriptor fontDescriptorByAddingAttributes:@{UIFontDescriptorTraitsAttribute : @{…
andypf
  • 197
  • 2
  • 10
1
vote
1 answer

How to to find the height of a single line of text using Text Kit

I'm trying to find the height of a single line of text using Text Kit. The Calculating Text Height documentation says Note: You don’t need to use this technique to find the height of a single line of text. The NSLayoutManager method …
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
1
vote
1 answer

UITextView scroll performance for large attributed strings

How can scroll performance of a UITextView be improved when using attributed strings? The following sample code results in completely unacceptable performance on an iPad 3. NSMutableParagraphStyle *pStyle = [[NSMutableParagraphStyle alloc]…
arsenius
  • 12,090
  • 7
  • 58
  • 76
1
vote
0 answers

Show large amount of attributed text efficiently using textkit without using paging

I have a large text file and I need to show it continuously, like one can do in textview. However, the rendering of the text takes a lot of time in UILable/UITextView. I have tried working with TextKit to only render the portion of the text visible…
Kamran Khan
  • 1,367
  • 1
  • 15
  • 19