Questions tagged [core-animation]

Core Animation is Apple's framework for performing hardware-accelerated animation of display elements on the Mac and iOS devices. Useful references include Core Animation Programming Guide Animation Types and Timing Programming Guide Core Animation Cookbook

core-animation
Filter by
Sorted by
Tagged with
201 votes
4 answers
111k views

How do I apply a perspective transform to a UIView?

I'm looking to perform a perspective transform on a UIView (such as seen in coverflow) Does anyonew know if this is possible? I've investigated using CALayer and have run through all the pragmatic ...
Nick Cartwright's user avatar
264 votes
28 answers
174k views

UIView Infinite 360 degree rotation animation?

I'm trying to rotate a UIImageView 360 degrees, and have looked at several tutorials online. I could get none of them working, without the UIView either stopping, or jumping to a new position. How ...
Derek's user avatar
  • 9,833
258 votes
18 answers
167k views

Cancel a UIView animation?

Is it possible to cancel a UIView animation while it is in progress? Or would I have to drop to the CA level? i.e. I've done something like this (maybe setting an end animation action too): [UIView ...
philsquared's user avatar
  • 22.5k
80 votes
4 answers
49k views

How can I animate the movement of a view or image along a curved path?

I am developing a commerce application. When I add an item to the shopping cart, I want to create an effect where an image of the item follows a curved path and ends up at the cart tab. How can I ...
user avatar
47 votes
10 answers
23k views

UIButton can't be touched while animated with UIView animateWithDuration

I have the following code: [UIView animateWithDuration:0.3 delay:0.0 options:UIViewAnimationCurveEaseOut | UIViewAnimationOptionAllowUserInteraction ...
Shai Mishali's user avatar
  • 9,332
142 votes
8 answers
214k views

iPhone UIView Animation Best Practice

What is considered best practice for animating view transitions on the iPhone? For example, the ViewTransitions sample project from apple uses code like: CATransition *applicationLoadViewIn = [...
Keith Fitzgerald's user avatar
55 votes
6 answers
32k views

Is there a way to pause a CABasicAnimation?

I have a basic spinning animation of the iPhone. Is there any way that I can "pause" the animation so that the position of the view will be maintained? I guess one way of doing this would be to cause ...
mclaughj's user avatar
  • 12.7k
143 votes
15 answers
53k views

Disabling implicit animations in -[CALayer setNeedsDisplayInRect:]

I've got a layer with some complex drawing code in its -drawInContext: method. I'm trying to minimize the amount of drawing I need to do, so I'm using -setNeedsDisplayInRect: to update just the ...
Ben Gottlieb's user avatar
  • 85.5k
51 votes
4 answers
50k views

iPhone Core Animation - Drawing a Circle

I wish to create an animation. The best way I can explain this is if you can imagine drawing a circle. It starts at the top or 12 o clock and draws clockwise all the way around until it becomes a ...
Benny's user avatar
  • 5,062
81 votes
11 answers
54k views

How to animate the background color of a UILabel?

This looks like it should work, but doesn't. The color turns green at once. self.labelCorrection.backgroundColor = [UIColor whiteColor]; [UIView animateWithDuration:2.0 animations:^{ self....
Michiel de Mare's user avatar
119 votes
6 answers
55k views

How to create custom easing function with Core Animation?

I am animating a CALayer along a CGPath (QuadCurve) quite nicely in iOS. But I'd like to use a more interesting easing function than the few provided by Apple (EaseIn/EaseOut etc). For instance, a ...
Martin Wickman's user avatar
44 votes
8 answers
25k views

Transforming a rectangle image into a quadrilateral using a CATransform3D

I have an image and a set of four points (describing a quadrilateral Q). I want to transform this image so that it is fits the quadrilateral Q. Photoshop calls this transformation "Distort." But ...
MonsieurDart's user avatar
  • 6,015
61 votes
3 answers
39k views

Objective-C - CABasicAnimation applying changes after animation?

I am using CABasicAnimation to move and resize an image view. I want the image view to be added to the superview, animate, and then be removed from the superview. In order to achieve that I am ...
aryaxt's user avatar
  • 77.1k
4 votes
2 answers
7k views

How to do animations using images efficiently in iOS

How can i do animation in iOS with out consuming much memory(or efficiently) as i am currently facing crash problems? For an single animation I am having a sequence of 100 images and each image is ...
prajul's user avatar
  • 1,216
92 votes
11 answers
35k views

How to animate the textColor property of an UILabel?

For some reason, when I try to animate textColor, it won't work. The textColor just suddenly changes from A to B. Is it possible to animate it, for example, red to black?
dontWatchMyProfile's user avatar
75 votes
3 answers
34k views

Draw segments from a circle or donut

I've been trying to figure out a way to draw segments as illustrated in the following image: I'd like to: draw the segment include gradients include shadows animate the drawing from 0 to n angle I'...
Chris Baxter's user avatar
  • 1,456
30 votes
3 answers
12k views

Animating a custom property of CALayer subclass

I have a CALayer subclass, MyLayer, that has a NSInteger property called myInt. I'd really like to animate this property via CABasicAnimation, but it seems CABasicAnimation only works on so-called "...
jemmons's user avatar
  • 18.6k
28 votes
3 answers
25k views

Can I use CGAffineTransformMakeRotation to rotate a view more than 360 degrees?

I'm writing an iPhone app, and I've got an image which I'ld like to have swirl outwards. Currently my code looks like this (wrapped in a beginAnimations/commitAnimations block): scale = ...
bwinton's user avatar
  • 1,978
55 votes
3 answers
46k views

What are block-based animation methods in iPhone OS 4.0?

I am trying to implement a game using the iPhone OS 4.0 (iOS4?) SDK. In the previous versions of the SDK, I've been using the [UIView beginAnimations:context:] and [UIView commitAnimations] to create ...
kkrizka's user avatar
  • 893
29 votes
5 answers
16k views

Create a custom animatable property

On UIView you can change the backgroundColour animated. And on a UISlideView you can change the value animated. Can you add a custom property to your own UIView subclass so that it can be animated? ...
Fogmeister's user avatar
  • 76.9k
24 votes
5 answers
31k views

How can I create a custom "pin-drop" animation using MKAnnotationView?

I have an instance of MKMapView and would like to use custom annotation icons instead of the standard pin icons supplied by MKPinAnnotationView. So, I've setup a subclass of MKAnnotationView called ...
user avatar
11 votes
1 answer
3k views

How do you achieve a "clock wipe"/ radial wipe effect in iOS?

Sometimes you'll see a "clock wipe" animation in use. Something like this: How would you achieve that effect in iOS? (Note: This question is a "ringer." I wanted to share a technique for creating a ...
Duncan C's user avatar
  • 130k
2 votes
4 answers
5k views

Method for animating images (like a movie) on iPhone without using MPMoviePlayer

I need to be able to display an animation over a static image. Given that MPMoviePlayer gives you no control over anything useful, the only way I can think to do this is to use multiple static ...
Ewan D's user avatar
  • 23
68 votes
8 answers
27k views

UIView animateWithDuration doesn't animate cornerRadius variation

I'm trying to animate the change of the cornerRadius of a UIView instance layer, but the variation of the cornerRadius takes place immediately. Here's the code: UIView *view = [[UIView alloc] ...
Francesco Puglisi's user avatar
20 votes
4 answers
11k views

Core animation progress callback

Is there an easy way to be called back when a Core Animation reaches certain points as it's running (for example, at 50% and 66% of completion ? I'm currently thinking about setting up an NSTimer, ...
tarmes's user avatar
  • 15.4k
76 votes
13 answers
33k views

iPhone "slide to unlock" animation

Any ideas as to how Apple implemented the "slide to unlock" (also, "slide to power off" is another identical example) animation? I thought about some sort of animating mask - but masking is not ...
user avatar
67 votes
10 answers
30k views

Restoring animation where it left off when app resumes from background

I have an endlessly looping CABasicAnimation of a repeating image tile in my view: a = [CABasicAnimation animationWithKeyPath:@"position"]; a.timingFunction = [CAMediaTimingFunction ...
Palimondo's user avatar
  • 7,371
65 votes
7 answers
65k views

CALayer: add a border only at one side

I can add a border to a CALayer in this way: [webView.layer setBorderColor: [[UIColor colorWithRed:0.6 green:0.7 blue:0.2 alpha:1] CGColor]]; [webView.layer setBorderWidth: 2.75]; But is it ...
Manni's user avatar
  • 11.1k
59 votes
10 answers
38k views

Test whether a UIView is in the middle of animation

Is there any way to tell if a UIView is in the middle of an animation? When I print out the view object while it is moving I notice that there is an "animations" entry: search bar should end editing:...
prostock's user avatar
  • 9,427
17 votes
3 answers
10k views

Does ARC work with Core Graphics objects?

I recently started a new project using Automatic Reference Counting (ARC). When I assigned the contents of a CALayer: UIView* view = ... UIImage* image = ... view.layer.contents = image.CGImage I ...
Pieter's user avatar
  • 17.6k
11 votes
4 answers
24k views

How to capture current view screenshot and reuse in code? (iPhone SDK)

I am attemting to transition from one UIView to another, when the user rotates the device. This, in of itself, is not difficult. However, since I am displaying completely different content after the ...
Carson C.'s user avatar
  • 2,372
110 votes
10 answers
53k views

How to identify CAAnimation within the animationDidStop delegate?

I had a problem where I had a series of overlapping CATransition / CAAnimation sequences, all of which I needed to perform custom operations when the animations stopped, but I only wanted one delegate ...
Batgar's user avatar
  • 1,529
88 votes
16 answers
49k views

UIView shake animation

i'm trying to make a UIView shake when a button is pressed. I am adapting the code I found on http://www.cimgf.com/2008/02/27/core-animation-tutorial-window-shake-effect/. However, by trying to ...
Jack Greenhill's user avatar
26 votes
2 answers
46k views

How do I pan the image inside a UIImageView?

I have a UIImageView that is displaying an image that is wider and taller than the UIImageView is. I would like to pan the image within the view using an animation (so that the pan is nice and smooth)....
TALlama's user avatar
  • 16.3k
79 votes
11 answers
61k views

Animation End Callback for CALayer?

I'm wondering where the callbacks are (or if there are anything) for animations in a CALayer. Specifically, for implied animations like altering the frame, position, etc. In a UIView, you could do ...
Jeffrey Forbes's user avatar
48 votes
8 answers
62k views

UIView vertical flip animation

I have an iOS UIView with UIViewAnimationTransitionFlipFromRight. I need it to flip vertically though. The page curl transition won't cut it. I assume this will require something custom. Any ideas?
Christian Schlensker's user avatar
34 votes
4 answers
22k views

Can't add a corner radius and a shadow

I'm trying to draw a shadow and a corner radius on an image. I can add them separately, but I've got no way to add both effects at the same time. I'm adding a shadow with: [layer setShadowOffset:...
Denis's user avatar
  • 417
9 votes
7 answers
14k views

Widget "flip" behavior in Core Animation/Cocoa

I'm trying to make a Card class that duplicates the behavior of Dashboard widgets in that you can put controls or images or whatever on two sides of the card and flip between them. Layer backed ...
user avatar
72 votes
3 answers
17k views

How is the relation between UIView's clipsToBounds and CALayer's masksToBounds?

A UIView has a CALayer. That's pretty sure. But both seem to provide something that means the same thing. If I'd set clipsToBounds=YES, would this also set the layer's masksToBounds=YES? Why ...
Thanks's user avatar
  • 40.3k
46 votes
6 answers
27k views

How to crossfade between 2 images on iPhone using Core Animation

I'm doing this to learn how to work with Core Animation animatable properties on iPhone (not to learn how to crossfade images, per se). Reading similar questions on SO leads me to believe it can be ...
willc2's user avatar
  • 39.3k
30 votes
5 answers
18k views

Cut Out Shape with Animation

I want to do something similar to the following: How to mask an image in IOS sdk? I want to cover the entire screen with translucent black. Then, I want to cut a circle out of the translucent black ...
ma11hew28's user avatar
  • 124k
23 votes
2 answers
5k views

UIView animations canceling any touch input?

I have a UIScrollView here where I'm adding displaying a label in the middle of the screen when the user has scrolled to a page, the problem is that while the animation is going the user can't scroll ...
Christian A. Strømmen's user avatar
45 votes
11 answers
21k views

Shake visual effect on iPhone (NOT shaking the device)

On login failure, I'd prefer to avoid showing an alert, it's too fleeting. Showing the alert and then showing the text somewhere on the login screen seems like duplication. So I'd like for it to ...
Steven Fisher's user avatar
38 votes
6 answers
22k views

Chaining Core Animation animations

Which is the most elegant and modular way to chain animation in a Core Animation context? I mean to do animations that starts just when other finished (for example, changing position and then ...
Jack's user avatar
  • 133k
34 votes
2 answers
26k views

How do you explicitly animate a CALayer's backgroundColor?

I'm trying to construct a CABasicAnimation to animate the backgroundColor property of a Core Animation CALayer, but I can't figure out how to properly wrap a CGColorRef value to pass to the animation. ...
Brad Larson's user avatar
  • 170k
31 votes
5 answers
19k views

drawViewHierarchyInRect:afterScreenUpdates: delays other animations

In my app, I use drawViewHierarchyInRect:afterScreenUpdates: in order to obtain a blurred image of my view (using Apple’s UIImage category UIImageEffects). My code looks like this: ...
Tim's user avatar
  • 8,389
24 votes
6 answers
6k views

When exactly do implicit animations take place in iOS?

Everyone and every book claims that there are implicit animations happening in CALayer. However, every time I wanted to verify that so far, I end up with a hard-snap to the set value. No animation at ...
Proud Member's user avatar
  • 40.4k
23 votes
5 answers
37k views

How to display a progress indicator overlay/HUD on iPhone?

I want to display a progress indicator in a semi-transparent box that floats over a table view. In other words, when the table contents are being downloaded, I want an "Updating" label to appear over ...
benzado's user avatar
  • 83.4k
22 votes
6 answers
37k views

How to animate the frame of an layer with CABasicAnimation?

I guess I have to convert the CGRect into an object to pass it to fromValue? This is how I try it, but it doesn't work: CABasicAnimation *frameAnimation = [CABasicAnimation animationWithKeyPath:@"...
dontWatchMyProfile's user avatar
22 votes
1 answer
21k views

How to animate CAShapeLayer path and fillColor

How to animate CAShapeLayer path and fillColor? How to animate strokeEnd to show the path being drawn? and how to animate fillColor?
MAMN84's user avatar
  • 1,420

1
2 3 4 5
15