0

I want to add image in UIView using coreText and then text around image like below.

eg..

    Baaa
img aaaa
    aaaa
aaaaaaaa
aaaaaaaa
aaaaaaaa

I want something like this where "img" is an image..and text start from "B"..

thanks..

AVJ
  • 144
  • 14

2 Answers2

0

You can find a complete working project if you look around here:

http://ios-blog.co.uk/tutorials/rich-text-editor-inserting-images-part-6/

It does exactly what you want but uses a UIWebView instead of CoreText.

Jeshua Lacock
  • 5,730
  • 1
  • 28
  • 58
0

Essentially when drawing with core text you are rendering text into paths. You can use the rect of a UIView or draw your own custom path into the current graphics context of a view.

so say you have the following rect:

xxxxxxxxxxx  
x         x  
x         x  
x         x  
x         x  
x         x  
x         x  
xxxxxxxxxxx  

you would need to draw your path around the image (p == path):

xxxxxxxxxxx  
xiiiiPPPPPx  
xiiiiP   Px  
xiiiiP   Px  
xPPPPP   Px  
xP       Px 
xPPPPPPPPPx   
xxxxxxxxxxx  

you would then tell CoreText to draw your text inside the path. As for actually drawing it - I suggest you read the apple docs - it explains it quite well.

hope this helps,

fatuous.logic
  • 750
  • 1
  • 5
  • 16