Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I translate parabolically?

I'm working on an iPhone app with some simple animation.

I have a view I want to translate, but not along a line. I want to translate it parabolically. Imagine that I am animating a car moving along a curved road.

I know I can set the transform properly to an instance of CGAffineTransform

Problem is, I have no idea how to create the transform. I know how to scale, translate, etc. but how do I translate parabolically? Is it even possible?

like image 673
bpapa Avatar asked Dec 11 '09 06:12

bpapa


People also ask

How to translate your Wordpress site?

However, this method can be costly if you hire a professional translator. On the other hand, Polylang is a free WordPress plugin you can use to translate your site. Not only can you add translations for posts and pages, but you can also create different versions of your menus and categories.

How do I translate a website that is not in English?

When you land on a page that isn’t in English, click on the Translate this page button in the address bar to open a popup. Then, select the option for English: The translation popup in Google Chrome. If you prefer, you can right-click the text you’d like translated and choose Translate to English:

How do I use Google Translate?

1 Go to the webpage you want to translate. 2 Click Translate when prompted. 3 If you don't see a Translate option, click the Google Translate logo in the far-right side of the address bar, then click Translate. 4 The Google Translate extension can be found here if you need machine translation.

How do I enable the beta version of translate to English?

When you visit a page in a foreign language, you can click on the aA button in the address bar to open a menu. There, you should see the Translate to English option. If this is the first time you’ve performed this action, you may receive a prompt asking you to enable the beta.


1 Answers

To animate along a smooth curve, you'll want to use a CAKeyframeAnimation. In this answer I provide code for a combined animation that moves an image view along a curve, while resizing it and fading it out. The relevant part of that code is as follows:

// Set up path movement
CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
pathAnimation.calculationMode = kCAAnimationPaced;
pathAnimation.fillMode = kCAFillModeForwards;
pathAnimation.removedOnCompletion = NO;

CGPoint endPoint = CGPointMake(480.0f - 30.0f, 40.0f);
CGMutablePathRef curvedPath = CGPathCreateMutable();
CGPathMoveToPoint(curvedPath, NULL, viewOrigin.x, viewOrigin.y);
CGPathAddCurveToPoint(curvedPath, NULL, endPoint.x, viewOrigin.y, endPoint.x, viewOrigin.y, endPoint.x, endPoint.y);
pathAnimation.path = curvedPath;
CGPathRelease(curvedPath);

This creates a curve with two control points, one at the origin of the view and the other at the upper-right corner of the the display (in landscape mode). For more on constructing paths, see the Quartz 2D Programming Guide or the Animation Types and Timing Programming Guide.

To use this animation, you'll need to add it to your view's layer using something like the following:

[imageViewForAnimation.layer addAnimation:pathAnimation forKey:@"curveAnimation"];
like image 100
Brad Larson Avatar answered Nov 09 '22 15:11

Brad Larson