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

  • Home
  • SEARCH
  • 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 6760457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:03:59+00:00 2026-05-26T14:03:59+00:00

I’d like to increase and decrease font size with pinch in and out. but

  • 0

I’d like to increase and decrease font size with pinch in and out. but the following Gesture is very slow. how to optimize it to work as a UIWebView.

- (void)viewDidLoad {  

       textView.text = @"fdsakllllllllllllllllllllllllllllllfadsjksadfjkjkasdfjkjksfjkdajkasfdjkjhasdfhhjasdfhadfjkskasfdjkjkahsfdjkasdfjkjkasfdkjfsdahkafsdjkadjksfjkajksdfjkasdfkafjksdajksdffdsakllllllllllllllllllllllllllllllfadsjksadfjkjkasdfjkjksfjkdajkasfdjkjhasdfhhjasdfhadfjkskasfdjkjkahsfdjkasdfjkjkasfdkjfsdahkafsdjkadjksfjkajksdfjkasdfkafjksdajksdffdsakllllllllllllllllllllllllllllllfadsjksadfjkjkasdfjkjksfjkdajkasfdjkjhasdfhhjasdfhadfjkskasfdjkjkahsfdjkasdfjkjkasfdkjfsdahkafsdjkadjksfjkajksdfjkasdfkafjksdajksdffdsakllllllllllllllllllllllllllllllfadsjksadfjkjkasdfjkjksfjkdajkasfdjkjhasdfhhjasdfhadfjkskasfdjkjkahsfdjkasdfjkjkasfdkjfsdahkafsdjkadjksfjkajksdfjkasdfkafjksdajksfsdjkadjksfjkajksdfjkasdfkafjksdajksdffdsakllllllllllllllllllllllllllllllfadsjksadfjkjkasdfjkjksfjkdajkasfdjkjhasdfhhjasdfhadfjkskasfdjkjkahsfdjkasdfjkjkasfdkjfsdahkafsdjkadjksfjkajksdfjkasdfkafjksdajksdffdsakllllllllllllllllllllllllllllllfadsjksadfjkjkasdfjkjksfjkdajkasfdjkjhasdfhhjasdfhadfjkskasfdjkjkahsfdjkasdfjkjkasfdkjfsdahkafsdjkadjksfjkajksdfjkasdfkafjksdajksdffdsakllllllllllllllllllllllllllllllfadsjksadfjkjkasdfjkjksfjkdajkasfdjkjhasdfhhjasdfhadfjkskasfdjkjkahsfdjkasdfjkjkasfdkjfsdahkafsdjkadjksfjkajksdfjkasdfkafjksdajksdf";

     UIPinchGestureRecognizer *pinchGesture =
     [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinchGesture:)];

     pinchGesture.delegate = self;
     /*textView.maximumZoomScale = 3;

     textView.minimumZoomScale = .5;
     */

     [textViewHadith addGestureRecognizer:pinchGesture];
     [pinchGesture release];

     // [textViewHadith setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"blackback ground.png"]]];


}

- (IBAction)handlePinchGesture:(UIGestureRecognizer *)sender {
    // static CGRect initialBounds;

    static int fontSize = 20;

    // UIView *_view = sender.view;

    if (sender.state == UIGestureRecognizerStateBegan)
        {
     //   initialBounds = _view.bounds;
        }
    CGFloat factor = [(UIPinchGestureRecognizer *)sender scale];


  //  NSLog(@"factor = %f",factor);


    if(factor > 1.0)
        {
        fontSize +=1;          

        }
    else
        {

        fontSize -= 1;

        }

   //    NSLog(@"font = %d",fontSize);
   if (fontSize >50) {
        fontSize =50; return;
    }

    if (fontSize <5) {
        fontSize = 5; return;
    }

    [textView setFont:[UIFont fontWithName:@"Helvetica" size:fontSize]];

  // CGAffineTransform zt = CGAffineTransformScale(CGAffineTransformIdentity, factor, factor);
   // _view.bounds = CGRectApplyAffineTransform(initialBounds, zt);
    return;
}


-(void) viewDidUnload
{
    textView = nil;
}

@end
  • 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-26T14:03:59+00:00Added an answer on May 26, 2026 at 2:03 pm

    Your code will increase or decrease the font size with every touch event, without regard to how much the fingers have moved. That will probably not give the users expected results.

    Instead you should record the font size when the gesture begins, and calculate the new font size relative to that based on the scale.

    For example

    fontSize = startFontSize * factor;
    

    Also, the code will run many times a second, and changing the font size is probably an expensive operation, because it must “reflow” the text.

    Instead, I would suggest a less expensive operation, just to give the users feedback that something is happening, but delaying the actual intended operation. Just set the transform on the view:

    view.transform = CGAffineTransformMakeScale(factor, factor);
    

    You might also want to adjust the bounds (and set clipsToBounds) so that it appears the view keeps the same frame and that the position in the text under the gesture stays in frame and in the same position.

    Then at the end of the gesture, reset the transform to identity and modify the font size.

    view.transform = CGAffineTransformIdentity;
    fontSize = startFontSize * factor;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have some data like this: 1 2 3 4 5 9 2 6
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but

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.