Aligning multiple sized text vertical center instead of baseline with Core Text in iOS

前端 未结 2 1821
半阙折子戏
半阙折子戏 2021-01-07 14:49

Is it possible to align multiple sized text by bounding center (of each size) instead of baseline?

I tried CTRunDelegate feature, but it doesn\'t work. It was possib

相关标签:
2条回答
  • 2021-01-07 15:28

    The run delegate methods getAscent and getDescent are, in fact, called (it is working in my own code). Of course, it makes sense that this doesn't change the baseline (and thus change how the text is displayed relative to other text on the line), as the ascent and descent are relative to the baseline.

    It would be handy to have maybe a getBaselineOffset but, unfortunately, that doesn't exist.

    My suggestion is to use the run delegate callbacks to reserve space for your differently-baselined text and then in a second pass, draw the other text with the different baseline.

    0 讨论(0)
  • 2021-01-07 15:35

    It was impossible still now. I'm regarding this is not possible for current version of Core Text.

    0 讨论(0)
提交回复
热议问题