Reputation: 2959
How do we get all four coordinates of a UIView? I thought this would be it.
CGPoint viewOriginX = [self.view convertPoint:self.view.frame.origin fromView:nil];
But what about CGPoint of the top right, bottom left and bottom right points?
Upvotes: 1
Views: 3284
Reputation: 57149
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));
If you need those coordinates in a particular view, the first line should be something like
CGRect frame = [self.view convertRect:[self.view bounds] toView:someOtherView];
Upvotes: 9