0

I am resizing a view with the setTransform method. Because i dont want the view to get too small, i got a check like this:

if(view.bounds.size.width > 100 && view.bounds.size.height > 100 && view.bounds.size.width < 300 && view.bounds.size.height < 300){
    //..resizing part
}

Now im confused. Normally i would transform my view with:

[view setTransform:scaleTransform];

But because im checking the view on its size i would suspect doing something like this:

CGAffineTransform scaleTransform = CGAffineTransformScale(view.transform, xScale, yScale);
CGRect newRect = CGRectApplyAffineTransform(view.frame, scaleTransform);
[view setBounds:newRect];

Is this correct or am i missing the link?

Oritm
  • 2,113
  • 2
  • 25
  • 40
  • Those two things are not the same. The first option actually scales the entire view and its content. The second option resizes the view bounds without resizing the content (more like a crop). Now if all of the content is able to resize properly due to UIAutoResizingMask setup, then the result may look equal. – Till Aug 24 '12 at 19:48
  • So whats your proposal, shouldnt i use CGAffineTransformScale but scale with setBounds? – Oritm Aug 24 '12 at 19:49
  • That depends on your needs. If resizing the bounds is good enough, then go with the second option. – Till Aug 24 '12 at 19:50

1 Answers1

0

What i did to solve this:

If the new frame is bigger than my provided bounds, dont translate. If its inside the provided bounds, set the new frame and translate.

Oritm
  • 2,113
  • 2
  • 25
  • 40