Questions tagged [nslayoutmanager]

Glyph layout engine in iOS and OSX

Responsible for converting characters drawn from NSTextStorage and laying them out as glyphs following the display/geometric constraints provided by one or more NSTextContainer.

120 questions
54
votes
1 answer

Swift protocols: method does not override any method from its superclass

Since Xcode 6 still has a lots of bugs with Swift, I'm not sure is it one or I'm missing something. My class adopts protocol NSLayoutManagerDelegate. But it seems impossible to override method I need. I do as documentation describes: override func…
Vitalii Vashchenko
  • 1,777
  • 1
  • 13
  • 23
37
votes
9 answers

Tap on a part of text of UILabel

I have a problem that boundingRectForGlyphRange always returns CGRect.zero "0.0, 0.0, 0.0, 0.0". For example, I am coding for touching on a part of text of UILabel feature. My text has first part is any text and second one is READ MORE. I want the…
Ashley
  • 499
  • 1
  • 6
  • 15
29
votes
3 answers

How does line spacing work in Core Text? (and why is it different from NSLayoutManager?)

I'm trying to draw text using Core Text functions, with a line spacing that's as close as possible to what it would be if I used NSTextView. Take this font as an example: NSFont *font = [NSFont fontWithName:@"Times New Roman" size:96.0]; The line…
Steven Vandeweghe
  • 2,170
  • 2
  • 20
  • 24
17
votes
1 answer

Animated UIImage in UITextView with TextKit

I have a UIImage that contains multiple image frames and a duration which was sliced together from an animated GIF file. If I load the image in a UIWebView it will animate as expected, but I want to use a UITextView instead. The obvious choice is to…
afrederick
  • 1,388
  • 1
  • 10
  • 24
17
votes
2 answers

Using NSLayoutManager to calculate frames for each glyph

On this thread, Core Text calculate letter frame in iOS, they were able to calculate the frame of each glyph very precisely using Core Text. The final rects hug the actual drawn glyphs perfectly. Using NSLayoutManager's…
jlmendezbonini
  • 2,239
  • 21
  • 25
14
votes
2 answers

Control spacing around custom text attributes in NSLayoutManager

I’ve got a custom NSLayoutManager subclass I’m using to draw pill-shaped tokens. I draw these tokens for substrings with a custom attribute (TokenAttribute). I can draw no problem. However, I need to add a little bit of “padding” around the ranges…
jbrennan
  • 11,943
  • 14
  • 73
  • 115
14
votes
1 answer

Creating animated text effects using NSLayoutManager?

In session 220 (Advanced Text Layouts and Effects with Text Kit) of WWDC 2013 they specifically say NSLayoutManager can be used in conjunction with NSTextStorage and NSTextContainer to create advanced text animations. They don't say how. I want to…
Rasto
  • 17,204
  • 47
  • 154
  • 245
12
votes
2 answers

Hide Markdown Characters with NSLayoutManager in Swift

I am working on a rich text editor in a Mac app that uses Markdown syntax. I use NSTextStorage to watch for matches in Markdown syntax, then apply styles to the NSAttributedString in real time like this: At this point, I'm already in way over my…
Clifton Labrum
  • 13,053
  • 9
  • 65
  • 128
12
votes
1 answer

Get line information from UITextView and NSLayoutManager

In order to support the UIAccessibilityReadingContent protocol, I need my UITextView to answer me questions about its lines. These are the methods of the protocol that I need to implement: accessibilityLineNumberForPoint: <- Provided a coordinate,…
Mikkel Selsøe
  • 1,171
  • 1
  • 11
  • 23
11
votes
3 answers

Subdivide a text view's attributed string into (referable) sections

I'm trying to implement a very simple text editor that should work both with NSTextView on macOS and UITextView on iOS. This text editor has a toolbar button "Section Break" that inserts a new section at the current cursor position every time it is…
Mischa
  • 15,816
  • 8
  • 59
  • 117
11
votes
1 answer

Performance of measuring text width in AppKit

Is there a way in AppKit to measure the width of a large number of NSString objects(say a million) really fast? I have tried 3 different ways to do this: [NSString sizeWithAttributes:] [NSAttributedString size] NSLayoutManager (get text width…
11
votes
3 answers

How to set up an NSTextView programmatically with explicit NSLayoutManager, NSTextStorage, NSTextContainer?

Following the apple documentation I am trying to set up a simple NSTextView via its two constructor methods. I am placing the below code inside the viewDidAppear method of the view controller of the content view. textView is an instance of…
Sam
  • 2,745
  • 3
  • 20
  • 42
10
votes
1 answer

UITableView in iOS 7 not scrolling to correct location when editing UITextView in cell

I have a table view with static cells. One cell contains a UITextView and the heightForRowAtIndexPath: is calculated dynamically so that the cell is always tall enough to accomodate the text (that part took some work under iOS 7, actually, as it's…
azsromej
  • 1,619
  • 13
  • 15
10
votes
1 answer

Autolayout is resizing my window

I have a nib with autolayout enabled containing a view controller's views and, separately, a window with a placeholder view to add them it into. The placeholder has constraints relative to its superview and other views in the window, and before…
Pierre Houston
  • 1,631
  • 20
  • 33
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.…
1
2 3 4 5 6 7 8