Questions tagged textkit

Explore the latest questions and answers asked by our top developers.

iOS Hyphenation with TextKit and justified text

Good day everyone. I have a problem with displaying hyphenated justified text using TextKit with a textview. I’ve tried to make hyphenation through paragraph style and NSLayoutManager, but without expected results. Paragraph style example: let paragraph = NSMutableParagraphStyle() paragraph.alignment = .justified paragraph.lineBreakMode = .byWordWrapping paragraph.hyphenationFactor = 0.85 //here goes the black magic 🙂 Problem is […]

By Igor Prusyazhnyuk
Published
Categorised as hyphenation, ios, justify, swift3, textkit

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. But when I cut and paste it (or archive/unarchive […]

By Morten J
Published
Categorised as nsattributedstring, nslayoutmanager, nstextview, swift, textkit

Character index at touch point for UILabel

For a UILabel, I’d like to find out which character index is at specific point received from a touch event. I’d like to solve this problem for iOS 7 using Text Kit. Since UILabel doesn’t provide access to its NSLayoutManager, I created my own based on UILabel‘s configuration like this: – (void)textTapped:(UITapGestureRecognizer *)recognizer { if […]

By Claus
Published
Categorised as ios7, objective-c, textkit

Adjust letter spacing in iOS 7

In iOS 7, when navigating back using the new swipe-from-edge-of-screen gesture, the title of the Back button (“Artists”) fades from being pink (in the example below) and having regular font weight to being black and having bold font weight. It seems to me that the animation uses two different labels in order to achieve this […]

By wstr
Published
Categorised as ios7, textkit, uilabel Tagged , ,

How do I locate the CGRect for a substring of text in a UILabel?

For a given NSRange, I’d like to find a CGRect in a UILabel that corresponds to the glyphs of that NSRange. For example, I’d like to find the CGRect that contains the word “dog” in the sentence “The quick brown fox jumps over the lazy dog.” The trick is, the UILabel has multiple lines, and […]

By bryanjclark
Published
Categorised as ios, ios7, textkit, uilabel Tagged , , ,

How to embed small icon in UILabel

I need to embed small icons ( sort of custom bullets ) to my UILabel in iOS7. How can I do this in interface designer? Or at least in code? In Android there are leftDrawable and rightDrawable for labels, but how it is done in iOS? Sample in android : Source: Ios7 Questions

By AVEbrahimi
Published
Categorised as cocoa-touch, ios, ios7, objective-c, textkit Tagged , , , ,

Rendering text in uppercase without changing the backing string? (iOS7 & Text Kit)

My application targets iOS 7 only. I have a UITextView presenting an NSAttributedString. The string represents a document, each paragraph has a number of attributes set on it for styling. Some paragraphs need to be rendered in ALL CAPS, however, the style of the paragraph could be changed by the user to something with regular […]

By James J
Published
Categorised as ios, ios7, textkit, uitextview Tagged , , ,

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq