iosresizesetboundscgaffinetransformscale

IOS setTransform and actual Bounds/Frame


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?


Solution

  • 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.