我们如何获得UIView的所有四个坐标?我以为这就是它。
CGPoint viewOriginX = [self.view convertPoint:self.view.frame.origin fromView:nil];
但是右上角,左下角和右下角的CGPoint呢?
答案 0 :(得分:7)
CGRect frame = [self.view frame];
CGPoint topLeft = CGPointMake(CGRectGetMinX(frame), CGRectGetMinY(frame));
CGPoint topRight = CGPointMake(CGRectGetMaxX(frame), CGRectGetMinY(frame));
CGPoint bottomLeft = CGPointMake(CGRectGetMinX(frame), CGRectGetMaxY(frame));
CGPoint bottomRight = CGPointMake(CGRectGetMaxX(frame), CGRectGetMaxY(frame));
如果您需要特定视图中的坐标,第一行应该是
CGRect frame = [self.view convertRect:[self.view bounds] toView:someOtherView];