在iphone视图中,Y轴相反,如何像Y轴数学一样调整它?

时间:2011-07-05 07:42:26

标签: iphone objective-c ios cgpoint

我想在iPhone的视图中点两分

这是我的代码

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];

这是point1,我设置的中心是X:60,Y:60

应该是这样的 enter image description here

但它在模拟器上运行就像这样...... enter image description here

如何在Y轴上调整POINT1中心???

非常感谢

韦伯。

1 个答案:

答案 0 :(得分:0)

视图上有一个setFlipped:方法。只需调用它并通过YES

[view setFlipped:YES]