core-animation

How can I terminate a running animation in iPhone-OS?

I have an class "Cube" and in there is a method -rotate. The method sets the anchorPoint at the bottom left and then rotates the cube by 90 degrees. After that, another method is called, which makes the cube to rotate back by -90 degrees. That's done specifying the stop selector. Btw: This has no special purpose. Just learning! -rotate ...

Fade in/out UIScrollView's content like Mobile Safari does in its tab

NOTE: I added my new solution at the UPDATE answer below. I try to recreate the effects we saw in Mobile Safari's tab on iPhone/iPod touch. Basically, it's a UIScrollView that holds 4 reusable UIView (acting like ring buffer), and scrolls horizontally. When scrolling, the UIView's opacity will fade in/out seamlessly with offset. Curr...

iPhone SDK: How to Draw a Rounded Rectangle With a Semi-Transparent Gradient and a Drop Shadow

I'm experimenting with drawing on the iPhone by manually creating parts of the UI for my application (In this case a graph). Essentially, I want to draw a rectangle with rounded corners, a drop-shadow, and a semi-transparent gradient as the fill of the rectangle. Here is a screen shot of my photoshop mockup: I've gotten has far as crea...

Is there a way to figure out, how many degrees an view is rotated currently during an animation?

I am applying an rotation transform animation in an animation block with this transform: CATransform3D rotatedTransform = self.layer.transform; rotatedTransform = CATransform3DRotate(rotatedTransform, 90 * M_PI / 180.0, 0.0f, 0.0f, 1.0f); self.layer.transform = rotatedTransform; The animation begins, and the user kicks in another even...

Iphone Core Animation coordinate tracking and collisions

Dear All, I'm currently learning Iphone programing and I'm having some trouble wrapping my mind around CAKeyframeAnimation I'm using CAKeyframeAnimation to animate objects on the screen like so: CGPathMoveToPoint(thePath, NULL, start.x, start.y); CGPathAddLineToPoint(thePath, NULL, finish.x, finish.y); animation.path = thePath; anima...

How can I get the current transform of the presentationLayer correctly?

I've tried this: CATransform3D rotationTransform = [[self.layer presentationLayer] transform]; This will not work, since the compiler will throw an warning and an error: Warning: Multiple methods "-transform" found. Error: Invalid initializer. So then I tried this: CATransform3D rotationTransform = [[self.layer presentationLa...

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 rotation, the default animation provided by UIKit (rotating the currently displayed view) is inappropriate conceptually. Simply disabling t...

Why does the transform of the presentationLayer represent the state of the finished animation, while the animation is running?

The documentation says: The presentation tree contains the values that are currently being presented to the user as an animation takes place. For example, setting a new value for the backgroundColor of a layer immediately changes the value in the layer tree. However, the backgroundColor value in the corresponding laye...

Is there a simple way to figure out, if two transforms are the same?

I've tried this, but that doesn't work: CATransform3D currentTransform = self.layer.transform; CATransform3D identityTransform = CATransform3DIdentity; if (currentTransform == identityTransform) NSLog(@"the same"); I really woulnd like to compare each single field in the matrix ;) Can I instad compare that somehow as a whole big thin...

What can I do with an CALayer delegate?

There seems to be an delegate that can be set like myView.layer.delegate = anObject The documentation just says: delegate Specifies the receiver’s delegate object. @property(assign) id delegate I wonder what kind of methods that delegate would implement, and when they would be called. Could solve some big problems ...

Why is finished always zero/NO when an animation ended and the delegate-method from the didEndSelector is called?

My delegate for ended animations looks like this: (void)animationDidEnd:(NSString *)animationID finished:(BOOL)finished context:(void *)context for some reason, the finished is always NO in my animation chain. But I need to know if an animation in my chain has finished completely. Example: Something says: "move to (20,100)". And as ...

Where is the difference between an "transform" and an "affine transform"?

There is a function like: CATransform3DGetAffineTransform Returns the affine transform represented by 't'. If 't' can not be exactly represented as an affine transform the returned value is undefined. I'm not so math-orientated, so a easy to understand description would be very nice. Wikipedia was no big help here. ...

How can I make a class with only class methods, that is capable of remembering values? How does Core Animation do that?

I have some useful methods for physics calculations like acceleration / deceleration, speed, and some more. Most of them require at least two measurements asunder in terms of time. So every time I want to use them, I have to implement a bunch of instance variables in my object that needs the calculation, for example for calculating an a...

iphone cocoa : how to drag an image along a path

I am trying to figure out how can you drag an image while constraining its movement along a certain path. I tried several tricks including animation along a path, but couldn't get the animation to play and pause and play backwards - so that seems out of the question. Any ideas ? anyone ? ...

Are there any tools or good techniques to find out where the performance bottlenecks are in an iPhone application?

I have an app that's half way done. The performance is not really good, and I wonder where the bottlenecks are. Although I can go ahead and start commenting out suspected lines of code, I wonder if there are any tools that would tell me which method cool took how long and what happened next. The stack trace isn't really that helpful. I ...

What is an "misaligned image" in terms of Core Animation in iPhone OS?

Instruments tells that there are "misaligned images" which are animated by core animation. What does that mean? UPDATE: I've seen that in Instruments.app > Core Animation. ...

Bad performance with core animation and view rotations: How to improve?

I have 12 views which I rotate almost similar to the icons in the home screen when going into homescreen-customization-mode by touching an icon for a few seconds. I use a 3D transformation code to do the rotations. They have each a duration of just 0.02 seconds, and the angle and direction of rotation changes permanently upon accelerati...

What's the equivalent for setting an "identity transform" in 2D space?

For 3D space, I use: self.layer.transform = CATransform3DIdentity; what corresponds here if I just need 2d space and want to assign the identity transform? I knew there was something, but I can't find it anymore. ...

Core Animation view is not displaying sometimes

I'm working on a Cocoa project using Core Animation and I've got a custom view that is displayed in two windows. It always shows up in one window, but sometimes does not show up in the other window when I start up the application. So far as I can tell, it is completely random. Here is the code I call when the view is initialized. It ...

How can I exclude a piece of code inside a core animation block from being animated?

I have an core animation block where I call a method that will load a view controller. there is an custom transition between two view controllers happening. However, when the view controller builds up the interface, all this stuff is affected by core animation. Although it results in some interesting effects, I don't want that ;) [UIVie...