0

I've made methods like follow and excute code.

I am confusing about origin of quartz framework after looking follow result image.

Please look at follow code and image.

[in ViewController.m]

Excute a follow method when press UIButton.

- (void)test {
    [customView drawCustom];
    [customView setNeedsDisplay];
}

[in CustomView.m]

- (void)drawRect:(CGRect)rect {
    cgc_Context = UIGraphicsGetCurrentContext();

    CGContextSetLineWidth(cgc_Context, 5.0);
    CGContextSetStrokeColorWithColor(cgc_Context, [UIColor redColor].CGColor);
    CGContextMoveToPoint(cgc_Context, 0, 0);
    CGContextAddLineToPoint(cgc_Context, 200, 50);
    CGContextStrokePath(cgc_Context);
}

- (void)drawCustom {
    CGContextSetLineWidth(cgc_Context, 5.0);
    CGContextSetStrokeColorWithColor(cgc_Context, [UIColor yellowColor].CGColor);
    CGContextMoveToPoint(cgc_Context, 0, 0);
    CGContextAddLineToPoint(cgc_Context, 200, 50);
    CGContextStrokePath(cgc_Context);
}

[Result screen]

Red Line : result of drawRect

Yellow Line : result of drawCustom

Why does occur different origin point?

enter image description here

S.J. Lim
  • 3,095
  • 3
  • 37
  • 55

1 Answers1

0

You must read the apple's documentation about Quartz 2D Coordinate Systems

tikhop
  • 2,012
  • 14
  • 32