core-animation

How can I use Core Animation to interpolate property values over time on my own classes?

Specifically, I am looking to use CA on properties of types other than integers and doubles CGRect, CGPoint, CGSize, and CGAffineTransform structures CATransform3D data structures CGColor and CGImage references and in objects other than CALayers or NSViews ...

How can I trigger Core Animation on an animator proxy during a call to resizeSubviewsWithOldSize?

I have some NSViews that I'm putting in one of two layouts depending on the size of my window. I'm adjusting the layout when the relevant superview receives the resizeSubviewsWithOldSize method. This works, but I'd like to animate the change. So naturally I tried calling the animator proxy when I set the new frames, but the animation ...

Easy way to scroll overflow text on a button?

Does anyone have any examples or resources where i might find information on scrolling text which is too long to display in a button control? I'm thinking something along these lines. Display as much text will fit within the current rect with a '...' at the end to signify overflow. Pause for say 1 second then slowly scroll the text to...

What's the best way to create a "magnifying glass" on a 2D scene?

I'm working on a game where I need to let the player look at a plane (e.g., a wall) through a lens (e.g., a magnifying glass). The game is to run on the iPhone, so my choices are Core Animation or OpenGL ES. My first idea (that I have not yet tried) is to do this using Core Animation. Create the wall and objects on it using CALayers....

Core Animation rotating a layer around arbitrary point

How can I rotate a layer using Core Animation around an arbitrary point? ( In my case a point that is not inside the layer I want to rotate ) I prefer doing this without changing the anchor point, because unless I get something wrong every time I change the anchor point it also changes the position of the layer. I tried something like ...

How do you move a CALayer instantly (w/o animation)

I'm trying to drag a CALayer in an iPhone app. As soon as I change its position property it tries to animate to the new position and flickers all over the place: layer.position = CGPointMake(x, y) How can I move CALayers instantly? I can't seem to get my head around the Core Animation API on the iPhone. Thanks a lot.. ...

After Animation, View position resets

I am trying to make a view slide from top to bottom. This is not a big deal, I used CABasicAnimation for this. The problem is when I want to remove the view. I use this animation. CABasicAnimation *animation; animation = [CABasicAnimation animationWithKeyPath:@"position"]; [animation setDelegate:self]; animation.toValue = [NSValue value...

How can I use custom animations for onOrderOut in Core Animation?

Core Animation allows for custom animations by implementing the actionForKey method in your CALayer based class: - (id<CAAction>)actionForKey:(NSString *)key { // Custom animations return [super actionForKey:key]; } I can then create an animation and return it for the onOrderIn action (i.e. when the layer is added to another layer)....

Timer and animation events trumping TouchesEnded events

Hi all, I've implemented a tap-and-hold handler using an NSTimer that I first set in the TouchesBegan overload. However, what I actually want is for an action to be continuously performed in quick-fire succession while the touch is being held. So, on timer expiry I call a handler to do the work, which then sets another timer and the cy...

Layer Backed Views and Flickering Controls

I have a window which contains an NSBox control. In that NSBox are several other controls, (popups, text fields, etc...) I have two other NSBox's in the same NIB file that are filled with controls that I would like to swap out with the first under certain conditions. I would like this to happen with a nice cross fade effect, so I do the...

How do I use CALayer with the iPhone?

Currently, I have a UIView subclass that "stamps" a single 2px by 2px CGLayerRef across the screen, up to 160 x 240 times. I currently animate this by moving the UIView "up" the screen 2 pixels (actually, a UIImageView) and then drawing the next "row". Would using multiple CALayer layers speed up performance of rendering this animation...

Image sequence animation with Core Animation

I'm currently using a UIImageView with an array of images to create a small looping animation sequence with about 20 images in there (at 320x480). Whilst this works okay for 20 - 30 images, any more and the app quits on the iphone. There is nothing else in my test app at the moment so I know it's just down to the animationImages sequence...

Delay with touch events

We have an app in AppStore Bust~A~Spook we had an issue with. When you tap the screen we use CALayer to find the position of all the views during their animation and if you hit one we start a die sequence. However, there is a noticeable delay, it appears as if the touches are buffered and we we receive the event to late. Is there a way...

CATransition showing a single frame from the end of the transition before the animation starts

I am using some code which was originally taken from the Apple sample ViewTransitions to swap two views with each other. CATransition *animation = [CATransition animation]; [animation setDelegate:self]; [animation setType:kCATransitionFade]; [animation setDuration:0.3f]; [animation setTimingFunction:[CAMediaTimingFunction functionWithNa...

Animation End Callback for CALayer?

Hi all. 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 something like this: [UIView beginAnimations:@"SlideOut" context:nil]; [UIView setAnimationDuration:.3]; [UIView setAnimationDelegate...

How can I retrieve the layer from a view?

I would like to do a transformation (rotation) to a UIImageView, I could just set the transform property of the view, but would setting the layer's transform make it faster? If so.. how can I achieve this? assuming I have a UIImageView initialized with an image, can anyone help? would it be better have a UIVIew with a UIImageView in it?...

How do I trigger a callback when a NSAnimationContext ends?

I have an animation which moves some views around. When this animation completes I want the window to recalculate the keyview loop. My code is simmilar to the follow mock code: [NSAnimationContext beginGrouping]; [newView setAlpha: 0.0]; //hide newView [self addSubView:newView]; //position the views [[oldView animator] setFrame...

UIView perspective transform

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 programmer Core Animation podcasts, but I'm still no clearer on how to create this kind of transform on an iPhone. Any help, pointers or e...

What's the difference between a CoreAnimation Layer Backed View and a Layer Hosting View?

What is the difference between a Layer Backed View and a Layer Hosting View in Core Animation? What are the steps to setting up each and when is it appropriate to use either type? ...

Affine Transformations vs Keyframing

This may be a silly question to a graphics guru (which I am not), but what's the difference between affine transformations and keyframing? I'm reading about the former in the iPhone cookbook, and she states that 'Affine transforms enable you to change an object's geometry by mapping that object from one view coordinate system into anothe...