1

I have CGRect with a default (square) size. The size is adjustable based on the view controllers needs, but always maintains a square proportion.

If I want to plot a point within the rect, but the scale of the rect is variable up and down in size, how would I calculate the new point position based on the change in rect size?

// in a UIView object, values always positive
- (CGPoint)convertPointToViewSizeScale:(CGPoint)point
{
    CGSize defaultSize = kViewSizeDefault;
    CGSize currentSize = self.frame.size;
    // ...
    return point;
}
TigerCoding
  • 8,710
  • 10
  • 47
  • 72

1 Answers1

3
point.x *= currentSize.width / defaultSize.width;
point.y *= currentSize.height / defaultSize.height;
rob mayoff
  • 375,296
  • 67
  • 796
  • 848