gpt4 book ai didi

ios - iPhone 像素坐标问题

转载 作者:行者123 更新时间:2023-11-29 04:18:30 24 4
gpt4 key购买 nike

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

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com