Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to know the current position of circle while it is rotating on custom route path?
    primarykey
    data
    text
    <p>I have used this code to animate the circle along a fixed custom route path along two buttons using their x &amp; y coordinates. Now I want to know the exact location of circle at each route while it is rotating or animating how could I know this?</p> <pre><code>- (void) animateCicleAlongPath:(NSInteger)pt1:(NSInteger)pt2 { UIButton *animatebtn1 = (UIButton *)[self.view viewWithTag:pt1]; UIButton *animatebtn2 = (UIButton *)[self.view viewWithTag:pt2]; NSLog(@"%@",animatebtn1); NSLog(@"%@",animatebtn2); NSLog(@"%@",NSStringFromCGRect(circleView.frame)); int a1; int a2; int b1; int b2; a1=animatebtn1.frame.origin.x; a2=animatebtn1.frame.origin.y; b1=animatebtn2.frame.origin.x; b2=animatebtn2.frame.origin.y; pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"]; [UIView setAnimationDidStopSelector:@selector(animationDidStart:)]; pathAnimation.calculationMode = kCAAnimationPaced; pathAnimation.fillMode = kCAFillModeForwards; pathAnimation.removedOnCompletion = YES; CGMutablePathRef curvedPath = CGPathCreateMutable(); CGPathMoveToPoint(curvedPath, NULL, b1, b2); NSLog(@"%@",[finalpath description]); for (int i=0; i&lt;finalpath.count; i++) { int j=[[finalpath objectAtIndex:i]intValue]; UIButton *animatebtn = (UIButton *)[self.view viewWithTag:j]; int p1=animatebtn.frame.origin.x; int p2=animatebtn.frame.origin.y; CGPathAddLineToPoint(curvedPath, NULL, p1,p2); } pathAnimation.path = curvedPath; CGPathRelease(curvedPath); UIGraphicsBeginImageContext(CGSizeMake(20,20)); // CGContextRef ctx = UIGraphicsGetCurrentContext(); //Set context variables CGContextSetLineWidth(context, 1.5); CGContextSetFillColorWithColor(context, [UIColor redColor].CGColor); CGContextSetStrokeColorWithColor(context, [UIColor whiteColor].CGColor); //Draw a circle - and paint it with a different outline (white) and fill color (green) CGContextAddEllipseInRect(context, CGRectMake(1, 1, 18, 18)); CGContextDrawPath(context, kCGPathFillStroke); UIImage *circle = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); circleView = [[UIImageView alloc] initWithImage:circle]; [imageScrollView addSubview:circleView]; [imageScrollView bringSubviewToFront:circleView]; [circleView setHidden:NO]; circleView.alpha=1; pathAnimation.speed=0.5; pathAnimation.duration=10; circleView.animationDuration=10; [circleView.layer addAnimation:pathAnimation forKey:@"moveTheSquare"]; [circleView release]; </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload