ios - iPhone 像素坐标问题

标签 ios screen coordinates linegraph

我正在尝试使用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/

相关文章:

ios - 在上传到服务器之前压缩视频和图像

objective-c - NSMutableAttributedString 在更改字体时崩溃?

ios - 将 PHAsset 附加到 PHAsset 数组

css - 根据屏幕分辨率更改 TD 字体大小

Android 在其他设备上共享显示

c++ - 我在 SFML sf::RenderWindow 中只有黑屏

ios - Realm - 匿名用户同步到新设备

Java - 平均线性图

ios - 如何将坐标原点设置为左侧和底部uiview

android - 在android dev中定位项目