2013-05-28 46 views

回答

2
CGPoint pointInSuperview = [superview convertPoint:pointInSubview fromView:subView]; 

實施例:

UIView *subView = [[UIView alloc] initWithFrame:CGRectMake(50, 50, 100, 100)]; 
[self.view addSubview:subView]; 

CGPoint pointInSubview = CGPointMake(20, 20); 
CGPoint pointInSuperview = [self.view convertPoint:pointInSubview fromView:subView]; 
NSLog(@"%@", NSStringFromCGPoint(pointInSuperview)); 

打印出{70, 70}到控制檯

+0

非常感謝。 –