Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6753277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:08:31+00:00 2026-05-26T13:08:31+00:00

I have a pinch gesture recognizer attached to an imageview from which I use

  • 0

I have a pinch gesture recognizer attached to an imageview from which I use pinches to enlarge and minimize the photo. Below is the code that I’m using in the delegate method:

- (void)scale:(UIPinchGestureRecognizer *)sender 
{
    if([sender state] == UIGestureRecognizerStateBegan) 
    {
        lastScale = [sender scale];
    }

    if ([sender state] == UIGestureRecognizerStateBegan || 
        [sender state] == UIGestureRecognizerStateChanged) 
    {

        CGFloat currentScale = [[[sender view].layer valueForKeyPath:@"transform.scale"] floatValue];


        CGFloat newScale = 1 -  (lastScale - [sender scale]) * (UIComicImageViewPinchSpeed); 
        newScale = MIN(newScale, minScale / currentScale);   
        newScale = MAX(newScale, maxScale / currentScale);
        CGAffineTransform transform = CGAffineTransformScale([[sender view] transform], newScale, newScale);
        [sender view].transform = transform;

        lastScale = [sender scale];   
    } 
}

I need to determine where the new center of the imageview frame will be before I actually perform the transformation. Is there anyway to determine this? Basically, I’m trying to halt the scaling if it’s about to move the image off the screen or close to it.

UPDATE

Thanks to Robin below for suggesting that method to figure out the transformed frame. The problem I’m running into now is that the frame becomes invalid after the transform is performed, and I need to keep track of the most recent frame in order to figure out the boundary of my image. Obviously, I can do this manually and store it in an instance variable, but wondering if there is a more “elegant” way to accomplish this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:08:31+00:00Added an answer on May 26, 2026 at 1:08 pm

    Use CGRectApplyAffineTransform like this:

    CGRect currentFrame = ....;
    
    CGRect newFrame = CGRectApplyAffineTransform(currentFrame, transform);
    
    // Then test if newFrame is within the limits you want
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a pinch gesture recognizer attached to my scrollView (one on top of
I have an imageView, to which, I have added UIPinchGestureRecognizer and UIRotationGestureRecognizer. in pinch
I have an application that allow user to use the pinch gesture for scaling
I have an image, which can be moved around and scaled with pinch gesture..
I have a map drawn with OpenGLES, and I have a pan gesture recognizer
I have an imageview that has a pinchgesturerecognizer attached to it. In the pinchgesturerecognizer
For my application, i have used pinch zoom feature by adapting from the tutorial
I have added the following gesture recognizer to my user control: UIRotationGestureRecognizer *rotate =
I have a view which the user can pinch to grow or shrink. I'd
have written this little class, which generates a UUID every time an object of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.