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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:18:50+00:00 2026-05-28T14:18:50+00:00

I want to simultaneously scale and translate a CALayer from one CGrect (a small

  • 0

I want to simultaneously scale and translate a CALayer from one CGrect (a small one, from a button) to a another (a bigger, centered one, for a view). Basically, the idea is that the user touches a button and from the button, a CALayer reveals and translates and scales up to end up centered on the screen. Then the CALayer (through another button) shrinks back to the position and size of the button.

I’m animating this through CATransform3D matrices. But the CALayer is actually the backing layer for a UIView (because I also need Responder functionality). And while applying my scale or translation transforms separately works fine. The concatenation of both (translation, followed by scaling) offsets the layer’s position so that it doesn’t align with the button when it shrinks.

My guess is that this is because the CALayer anchor point is in its center by default. The transform applies translation first, moving the ‘big’ CALayer to align with the button at the upper left corner of their frames. Then, when scaling takes place, since the CALayer anchor point is in the center, all directions scale down towards it. At this point, my layer is the button’s size (what I want), but the position is offset (cause all points shrank towards the layer center).

Makes sense?

So I’m trying to figure out whether instead of concatenating translation + scale, I need to:

translate

change anchor point to upper-left.

scale.

Or, if I should be able to come up with some factor or constant to incorporate to the values of the translation matrix, so that it translates to a position offset by what the subsequent scaling will in turn offset, and then the final position would be right.

Any thoughts?

  • 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-28T14:18:51+00:00Added an answer on May 28, 2026 at 2:18 pm

    You should post your code. It is generally much easier for us to help you when we can look at your code.

    Anyway, this works for me:

    - (IBAction)showZoomView:(id)sender {
        [UIView animateWithDuration:.5 animations:^{
            self.zoomView.layer.transform = CATransform3DIdentity;
        }];
    }
    
    - (IBAction)hideZoomView:(id)sender {
        CGPoint buttonCenter = self.hideButton.center;
        CGPoint zoomViewCenter = self.zoomView.center;
        CATransform3D transform = CATransform3DIdentity;
        transform = CATransform3DTranslate(transform, buttonCenter.x - zoomViewCenter.x, buttonCenter.y - zoomViewCenter.y, 0);
        transform = CATransform3DScale(transform, .001, .001, 1);
        [UIView animateWithDuration:.5 animations:^{
            self.zoomView.layer.transform = transform;
        }];
    }
    

    In my test case, self.hideButton and self.zoomView have the same superview.

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

Sidebar

Related Questions

I want to open Multiple Instance of a single from , and running simultaneously
How can I express to PostgreSQL that I want values simultaneously from several hierarchical
So I want users to be able to login from different computers simultaneously. So
I want to copy data from two columns in a 'table1' to another table
I want to make a movement of 3 images simultaneously when they are one
i want simultaneously read and write data into file. Can i use StreamReader and
I want my python script to simultaneously accept POST variables and query string variables
What is the pythonic way of iterating simultaneously over two lists? Suppose I want
want to have a Hyperlink-Button in a gridView in which I can display a
I want to gain more insight regarding the scale of workload a single-server Java

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.