2011-07-05 100 views
0

我想鞋在iPhone的視圖兩點在iphone的視角中,Y軸相反,如何調整它像Y軸數學?

這是我的代碼

UIImageView *center; 
center = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"point.png"]]; 
[center setFrame:CGRectMake(0, 0, 10, 10)]; 
float r_rect_center_x = [r_img frame].size.width/2; 
float r_rect_center_y = [r_img frame].size.height/2; 
[center setCenter:CGPointMake(r_rect_center_x,r_rect_center_y)]; 
[r_img addSubview:center]; 
[center release]; 

這是中心,我得到的結果中心點(X:50 Y:60)

float point1_x = 60.0f; 
float point1_y = 60.0f; 
UIImageView *point1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"point.png"]]; 
[point1 setFrame:CGRectMake(0, 0, 10, 10)]; 
[point1 setCenter:CGPointMake(point1_x,point1_y)]; 
[r_img addSubview:point1]; 
[point1 release]; 

這是點1,我設置了中心X:60 Y:60成

它應該是這個樣子的 enter image description here

但在模擬器上運行的是這樣的... enter image description here

如何調整POINT1中心Y軸???

非常感謝

韋伯。

+0

的可能重複[如何在上下文中繪製時翻轉座標?](http://stackoverflow.com/questions/1145595/how-to-flip-coordinates-when-drawing-in-context) –

回答

0

視圖上有一個setFlipped:方法。只需調用它並通過YES即可。

[view setFlipped:YES] 
+0

你的意思是[self.view setFlipped:YES] ??? –

+0

我試試這個,CGAffineTransform transform = CGAffineTransformIdentity; \t r_img.transform = CGAffineTransformRotate(transform,-90 * M_PI/180); 但只能互相作用...... –