How to draw images among rich-text with CoreText? (iOS)

后端 未结 2 1477
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-30 12:17

I can draw rich-text with Core Text, the problem is placing images flowing with the text. (iOS SDK 4.1)

I\'m try to drawing some kind of rich-text. Problem is designer p

2条回答
  •  礼貌的吻别
    2021-01-30 12:37

    You simply set a delegate for a given CTRun and the delegate object is responsible to let know Core Text what is the CTRun ascent space, descent space and width.

    When Core Text "reaches" a CTRun which has a CTRunDelegate it asks the delegate - how much width should I leave for this chunk of data, how high should it be? This way you build a hole in the text - then you draw your image in that very spot.

    enter image description here

    Here is a blog about Core Text.It has the answer for you .

    How To Create a Simple Magazine App with Core Text

提交回复
热议问题