1

I see there is a class ASTextKitRenderer, but I'm not sure the proper usage of this and how to import it into my swift project.

I want to recreate the behavior of minimumScaleFactor of UILabel for ASTextNode

Kevin
  • 1,883
  • 16
  • 23
  • I just found in ASTextNode+Beta.h the mysterious pointSizeScaleFactors, but not sure how to get the text to re-layout if it's over the frame size – Kevin Mar 30 '16 at 01:10

2 Answers2

11

Just spent 2 hours searching for the same finally came up with the solution, you just have to use

_textNode.pointSizeScaleFactors = @[@(0.5)];

as the documentation says

An array of descending scale factors that will be applied to this text node to try to make it fit within its constrained size. This array should be in descending order and NOT contain the scale factor 1.0. For example, it could return @[@(.9), @(.85), @(.8)]; defaults to nil (no scaling)

Have a look at this

Vikas
  • 720
  • 1
  • 9
  • 30
Nitish Makhija
  • 559
  • 5
  • 20
0

Is not necessary to use the renderer class directly, and in fact this is not a necessary step to solve your problem. As you pointed out, there is a usable API in Beta that has this behavior, and you can also look at the open source project for the changes that landed this functionality for some additional details on how to use it.

Michał Perłakowski
  • 88,409
  • 26
  • 156
  • 177