I have an NSView which has in its "drawRect:" method:

    NSColor *backgroundColor = [NSColor colorWithPatternImage:self.image];
    [backgroundColor setFill];

...

the image method does:

  -(NSImage *)image {
      if (!_image) {
          _image = [[NSImage alloc] initWithSize:self.bounds.size];

          [_image lockFocus];
          [[NSColor blueColor] set];
          NSBezierPath *line = [NSBezierPath bezierPath];

          NSPoint pointA = NSMakePoint(0, 0);
          NSPoint pointB = NSMakePoint(self.bounds.size.width, 0);

          [line moveToPoint:pointA];
          [line lineToPoint:pointB];
          [line stroke];
      }
    return _image;
  }

The resulting line is drawn off center (somewhere around -10px) from the middle
of the NSView...  I would like to have my 0,0 origin be the bottom left corner
of the NSView as I would get if I were to put this line directly in the
drawRect (not using an NSImage): method..

What am I doing wrong here?

Patrick J. Collins
http://collinatorstudios.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to