【问题标题】:iPhone Pixel Coordinate IssueiPhone像素坐标问题
【发布时间】:2012-11-11 22:51:26
【问题描述】:

我正在尝试使用 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);
}

【问题讨论】:

    标签: ios screen coordinates linegraph


    【解决方案1】:

    This page 描述了如何将其视为右手坐标系而不是左手坐标系,这听起来像你想要的

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-03-31
      • 2011-12-04
      • 2023-04-06
      • 2011-04-17
      • 1970-01-01
      • 2014-11-05
      • 2020-06-10
      相关资源
      最近更新 更多