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 7900467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:58:40+00:00 2026-06-03T08:58:40+00:00

i am trying to scale in and out a UIButton in the main view,

  • 0

i am trying to scale in and out a UIButton in the main view, when i press a action button at first, the button zooms in and when i press it again it zooms out but when i press it again to zoom in.. nothing happens.. here is my code:

THE METHODS TO ZOOM IN AND ZOOM OUT ARE IN A OBJECTIVE-C CATEGORY ON UIVIEW

- (void)viewDidLoad
[super viewDidLoad];

//this button is being added in the storyboard
[self.viewToZoom removeFromSuperview];

}

- (IBAction)zoomButton:(id)sender {

if (isShown) {
    [self.view removeSubviewWithZoomOutAnimation:self.viewToZoom duration:1.0 option:0];
    isShown = NO;
} else {
    [self.view addSubviewWithZoomInAnimation:self.viewToZoom duration:1.0 option:0];
    isShown = YES;
}

}

UIView+Animation.m


- (void) addSubviewWithZoomInAnimation:(UIView*)view duration:(float)secs option:(UIViewAnimationOptions)option {

CGAffineTransform trans = CGAffineTransformScale(view.transform, 0.01, 0.01);

view.transform = trans; // do it instantly, no animation
[self addSubview:view];
// now return the view to normal dimension, animating this tranformation
[UIView animateWithDuration:secs delay:0.0 options:option
                 animations:^{
                     view.transform = CGAffineTransformScale(view.transform, 100.0, 100.0);
                 }
                 completion:^(BOOL finished) {
                     NSLog(@"done");
                 } ];   
}


- (void) removeSubviewWithZoomOutAnimation:(UIView*)view duration:(float)secs option:(UIViewAnimationOptions)option {

// now return the view to normal dimension, animating this tranformation
[UIView animateWithDuration:secs delay:0.0 options:option
                 animations:^{
                     view.transform = CGAffineTransformScale(view.transform, 0.01, 0.01);

                 }
                 completion:^(BOOL finished) {
                     [view removeFromSuperview];
                 }];    
}

Thanks,
Newton

  • 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-06-03T08:58:42+00:00Added an answer on June 3, 2026 at 8:58 am

    Newton, when removeSubviewWithZoomOutAnimation ends the view.transform is an affine transform that scaled the view’s original size down to 0.01. The problem is that when you call addSubviewWithZoomInAnimation the second time you’re again scaling down by 0.01, but now the view.transform will be scaled down to 0.0001, which is not what you’re looking for.

    Simply add view.transform = CGAffineTransformIdentity; at the beginning of both animations like this:

    - (void) addSubviewWithZoomInAnimation:(UIView*)view duration:(float)secs option:(UIViewAnimationOptions)option {
        view.transform = CGAffineTransformIdentity; 
        CGAffineTransform trans = CGAffineTransformScale(view.transform, 0.01, 0.01);
    
        view.transform = trans; // do it instantly, no animation
        [self addSubview:view];
        // now return the view to normal dimension, animating this tranformation
        [UIView animateWithDuration:secs delay:0.0 options:option
                         animations:^{
                             view.transform = CGAffineTransformScale(view.transform, 100.0, 100.0);
                         }
                         completion:^(BOOL finished) {
                             NSLog(@"done");
                         } ];   
    }
    
    
    - (void) removeSubviewWithZoomOutAnimation:(UIView*)view duration:(float)secs option:(UIViewAnimationOptions)option {
        view.transform = CGAffineTransformIdentity;
        // now return the view to normal dimension, animating this tranformation
        [UIView animateWithDuration:secs delay:0.0 options:option
                         animations:^{
    
                             view.transform = CGAffineTransformScale(view.transform, 0.01, 0.01);
    
                         }
                         completion:^(BOOL finished) {
    
                             [view removeFromSuperview];
                         }];    
    }
    

    I also suggest you to pass the UIViewAnimationOptionBeginFromCurrentState UIViewAnimationOptions which improves the animation result when quickly zooming in and out.

    Hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to scale text from 1 to 5, a sort of zoom in
I'm trying to translate and scale a view in the same block. For some
I'm trying to scale a container/parent movie clip up so that I effectively zoom
I'm trying to scale this but I'm a little green when it comes to
Im trying to work out the best way scale my site, and i have
I'm trying to animate some text 'zooming out' on top of another view. My
I am trying to implement pinch zoom and it is working but when i
I'm trying to get started with Scala and cannot get out of the starting
I've been trying to work out how to implement Church-encoded data types in Scala.
Basically i am trying to scale an img with an id=room according to a

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.