我正在尝试使用drawRect方法制作折线图,但遇到了一个主要问题。 iPhone 屏幕上的 0 点位于左上角。有没有办法重新定位 0,0 点或将输入的坐标更改为 0,0 点位于左下角时的位置?
这是我的drawRect方法
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 1.0);
CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
CGFloat components[] = {0.0, 0.0, 1.0, 1.0};
CGColorRef color = CGColorCreate(colorspace, components);
CGContextSetStrokeColorWithColor(context, [UIColor blackColor].CGColor);
//Coordinates of bottom left corner (480 went off screen)
CGContextMoveToPoint(context, 0, 460);
CGContextAddLineToPoint(context, 320, 0);
CGContextStrokePath(context);
CGColorSpaceRelease(colorspace);
CGColorRelease(color);
}
最佳答案
This page描述了如何将其视为右手坐标系而不是左手坐标系,这听起来像你想要的
关于ios - iPhone 像素坐标问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13336320/