0

i don't worked enougth with core text, but as i thought it's only possible way to do this, but who knows. So i have a server, that sends me information:

NSString *text = @"hello, today is best day";
NSArray *images; // array of url's from server to images (http://80.89.ru/123.png ....) 
// I don't know how many url's there will be

I have a window, in this window i need to correctly draw UILabel with that string and all images, that i get from server with this text. So i configured UILabel in InterfaceBuilder and config my label with images into ViewController

@interface ViewC()
{
   UILabel *longStringFromServer;
}

- (void)viewDidLoad
{
    int y = 20; int x = 20;
    for (NSString *url in images)
    {
        UIImageView *view = [UIImageView alloc] initWithFrame....];
        y += 50; 
        // load image by url into UIImageView
    }
    longStringFromServer = text;
}

What I have:

enter code here

What I need:

enter image description here

How do i can reach that result on second picture ?

brandonscript
  • 68,675
  • 32
  • 163
  • 220
  • I can't look now but you can create exclusion regions when rendering with core text. This will wrap the text around the region. Add the image frames as exclusion regions. – Fogmeister Nov 12 '14 at 20:27
  • Does this regions can create dynamically in case of images number ? Can you give me example of how to do this with NSString and UILabel ? – user3853693 Nov 12 '14 at 20:32
  • possible duplicate of [How Can I Draw Image with Text Wrapping on iOS?](http://stackoverflow.com/questions/5284516/how-can-i-draw-image-with-text-wrapping-on-ios) – brandonscript Nov 12 '14 at 20:37
  • Also a great tutorial on doing this: http://robnapier.net/wrapping-text-around-shape-with-coretext – brandonscript Nov 12 '14 at 20:37
  • 1
    Use TextKit and the exclusionPaths for the NSTextContainer might help you in this case. – Sandeep Nov 12 '14 at 20:43

0 Answers0