0

In my application I have an array of strings that I am trying to draw in a pop over. Previously, I have been able to draw images in the pop over, but trying to convert this to show text I have not been successful. Listed below is the function I just to get the images from the array, and draw them.

CGRect b = self.bounds;


      CGFloat columnWidth = b.size.width / columnCount;
      CGFloat rowHeight = b.size.height / rowCount;

      for (NSUInteger rowIndex = 0; rowIndex < rowCount; rowIndex++) {
          for (NSUInteger columnIndex = 0; columnIndex < columnCount; columnIndex++) {
              CGRect r = CGRectMake(b.origin.x + columnIndex * columnWidth,
                                    b.origin.y + rowIndex * rowHeight,
                                    columnWidth, rowHeight);
              UIImage *image = [self.colors objectAtIndex:rowIndex * columnCount + columnIndex];
              [image drawInRect:r];



          }
      }

In this function (for the text, not the one above), the row and column count have sometimes changes - for the text display, columns is always 1, and the rows are always equal to the amount of items in the array (for our testing purposes, there is 1 string in the array currently) I have tried to make the image a UIlabel instead, and changing the test of the label to the item in the string - but it still does not display when using drawInRect. Does anyone have a solution to this? I basically need to find any way to draw this text in the rect, even if its not using a label and another method (like placing the text in an image, which I also was not able to figure out). Thanks for your help.

njj56
  • 611
  • 4
  • 19
  • 51
  • please post the code related to issue, issue is with text not with image. So post the code which you have the issue. – Midhun MP Nov 09 '12 at 14:43
  • not really sure what you are asking for, this code is the drawRect for the images that works, I could post the code for the text, but the only changes are the UIImage *image line is UILabel *label; then the next line is label.text = [self.colors objectAtIndex:0]; - then [label drawInRect:r]; – njj56 Nov 09 '12 at 14:49
  • Refer http://stackoverflow.com/questions/2697440/how-to-draw-an-uilabel-in-drawrect and http://stackoverflow.com/questions/4388384/adding-a-drop-shadow-to-nsstring-text-in-a-drawrect-method-without-using-uilabe – Midhun MP Nov 09 '12 at 14:56
  • thanks, the issue was missing the withFont part of draw in rect when doing this with just a string. – njj56 Nov 09 '12 at 15:09

0 Answers0