2012-11-11 124 views
0

我正在嘗試使用drawRect方法制作線圖,但遇到了一個主要問題。 iPhone屏幕上的0點位於左上角。如果0,0點位於左下角,是否有任何方法可以重新定位0,0點或將座標輸入更改爲它們將會出現的位置?iPhone像素座標問題

繼承人我的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); 
} 

回答

1

This page介紹瞭如何把它當作一個右手座標,而不是左手系統,這聽起來像你想

什麼