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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:30:13+00:00 2026-06-06T08:30:13+00:00

I am trying to animate the width of a rounded rectangle, the problem is

  • 0

I am trying to animate the width of a rounded rectangle, the problem is when going from bigger width to thinner width, the animation does an “aberration ease jump”.

Here’s the code:

shapeLayer = [CAShapeLayer layer];
shapeRect = CGRectMake(0.0f, 0.0f, 150.0f, 200.0f);
[shapeLayer setBounds:shapeRect];
[shapeLayer setPosition:CGPointMake(iniPosX, 80.0f)];
[shapeLayer setFillColor:[[UIColor blackColor] CGColor]];
[shapeLayer setStrokeColor:[[UIColor clearColor] CGColor]];
[shapeLayer setLineWidth:1.0f];
[shapeLayer setLineJoin:kCALineJoinRound];
[shapeLayer setOpacity:0.2];
path = [UIBezierPath bezierPathWithRoundedRect:shapeRect cornerRadius:15.0];
[shapeLayer setPath:path.CGPath];
[self.layer addSublayer:shapeLayer];

And when I start the animation:

- (void)adjustSelectorToPosAndSize:(float)posX andWidth:(float)width
{
    shapeRect = CGRectMake(0.0f, 0.0f, width, 200.0f);
    [shapeLayer setBounds:shapeRect];
    [shapeLayer setPosition:CGPointMake(posX, 80.0f)];
    path = [UIBezierPath bezierPathWithRoundedRect:shapeRect cornerRadius:15.0];
    [shapeLayer setPath:path.CGPath];
}

What am I doing wrong?

  • 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-06T08:30:15+00:00Added an answer on June 6, 2026 at 8:30 am

    Doing this with a CAShapeLayer seems overly complicated to me if you are only using it for a rounded rectangle. Why not simply use a CALayer with the cornerRadius properly set?

    Animating the frame with cornerRadius set will work fine.

    myLayer = [CALayer layer];
    shapeRect = CGRectMake(0.0f, 0.0f, 150.0f, 200.0f);
    [myLayer setBounds:shapeRect];
    [myLayer setPosition:CGPointMake(iniPosX, 80.0f)];
    [myLayer setBackgroundColor:[[UIColor blackColor] CGColor]];
    [myLayer setBorderColor:[[UIColor clearColor] CGColor]];
    [myLayer setBorderWidth:1.0f];
    [myLayer setOpacity:0.2];
    [myLayer setCornerRadius:15.0];
    [self.layer addSublayer:myLayer];
    

    Animating it is done by simply chaining the frame (not the path)

    - (void)adjustSelectorToPosAndSize:(float)posX andWidth:(float)width
    {
        shapeRect = CGRectMake(0.0f, 0.0f, width, 200.0f);
        [myLayer setBounds:shapeRect];
        [myLayer setPosition:CGPointMake(posX, 80.0f)];
    }
    

    Important:

    Some of the properties changed name like fillColor became backgroundColor and the strokeColor and lineWidth became borderColor and borderWidth etc.

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

Sidebar

Related Questions

I am trying to animate menu elements shrinking the width from 170 to 150px
I am trying to make only the li:nth-child(2) width animate from 230px to 780px
I'm trying to animate a dot from one point to another on a map.
All, I am trying create a 'to & fro' animation using jquery animate &
I'm trying to animate a UIButton. But during it's animation, there is no interaction
I'm trying to animate a UIWebview being removed from the screen. I'm using an
I am trying to animate the width of a div which is wrapped by
I'm using jQuery and trying to animate a <select> box where the width would
Like i said in title, im trying to animate a element width with js:
I'm trying to do a simple width and background color animation with jQuery (similar

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.