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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:00:01+00:00 2026-05-26T10:00:01+00:00

i have a circle image that circles round the screen using a path animation.

  • 0

i have a circle image that circles round the screen using a path animation. And i want to detect when the user touches the moving circle. However even though the image is moving round in a continuous circle its frame is still in the top left hand corner not moving, how can i update this so that i can detect a touch on the moving image? Here is the code…

Set Up Animation in ViewDidLoad:

//set up animation
CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
pathAnimation.calculationMode = kCAAnimationPaced;
pathAnimation.fillMode = kCAFillModeForwards;
pathAnimation.removedOnCompletion = NO;
pathAnimation.duration = 10.0;
pathAnimation.repeatCount = 1000;
CGMutablePathRef curvedPath = CGPathCreateMutable();

//path as a circle
CGRect bounds = CGRectMake(60,170,200,200);
CGPathAddEllipseInRect(curvedPath, NULL, bounds);

//tell animation to use this path
pathAnimation.path = curvedPath;
CGPathRelease(curvedPath);

//add subview
circleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ball.png"]];    
[testView addSubview:circleView];

//animate
[circleView.layer addAnimation:pathAnimation forKey:@"moveTheSquare"];

Touches Method:

- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

    //detect touch
    UITouch *theTouch = [touches anyObject];

    //locate and assign touch location
    CGPoint startPoint = [theTouch locationInView:self.view];    
    CGFloat x = startPoint.x;
    CGFloat y = startPoint.y;

    //create touch point
    CGPoint touchPoint = CGPointMake(x, y);

    //check to see if the touch is in the rect    
    if (CGRectContainsPoint(circleView.bounds, touchPoint)) {       

        NSLog(@"yes");
    }

    //check image view position
    NSLog(@"frame x - %f, y - %f", circleView.frame.origin.x, circleView.frame.origin.y);
    NSLog(@"center x - %f, y - %f", circleView.center.x, circleView.center.y);
    NSLog(@"bounds x - %f, y - %f", circleView.bounds.origin.x, circleView.bounds.origin.y);

}

the imageview just seems to stay at the top left hand corner. I cant seem to figure out how to recognise if a touch gesture has been made on the moving ball.

any help would be appreciated,

Chris

  • 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-26T10:00:02+00:00Added an answer on May 26, 2026 at 10:00 am

    You need to query the presentation layer of the view not it’s frame. Only the presentation will be updated during the course of an animation…

    [myImageView.layer presentationLayer]
    

    Access the properties of this layer (origin, size etc) and determine if your touch point is within the bounds.

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

Sidebar

Related Questions

I have an image that the user can zoom/scroll. I want to draw some
let's say we have an image that contain square,circle and other few object at
I have a PNG image that uses transparency (it is actually a circle with
i want to crop image via drawing circle using touchMoved event. so how can
Suppose I have an image that is a black circle PNG. (transparent background, black
I have a circle image that's fairly large in size to make it easy
I have a image in the shape of a Circle. The circle is broken
I have an NSView in which the user can draw circles. These circles are
Going round in circles here i think. I have an activity called Locate; public
I have a complex background image and images, that should be on exact positions

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.