calayer

Animating a CALayer's mask size change

I have a UIView subclass which uses a CAShapeLayer mask on its CALayer. The mask uses a distinct shape, with three rounded corners and a cut out rectangle in the remaining corner. When I resize my UIView using a standard animation block, the UIView itself and its CALayer resize just fine. The mask, however, is applied instantly, which l...

how do i get a layer's frame to automatically resize based on its superlayer's frame or its view's frame?

I'm experimenting with using cagradientlayer to draw gradients in our app instead of having a subclass of uiview manage gradients. One snafu that i've come across is that when the view that has the gradient as a sublayer of its main layer gets resized to fit the data i am trying to show, the layer doesn't resize along with it. I end up...

Hit Testing with CALayer using the alpha properties of the CALayer contents.

I'm writing a game for Mac using Cocoa. I'm currently implementing hit testing and have founds that CALayer offers hit testing, but does not seem to implement the alpha properties. As I have at times many CALayers stacked on top of each other, I really need to find a way to determine what the user actually meant to click on. I'm thinki...

How can I create "glass" effect on my own UIViews?

Hi there, I'm working on an iPhone app that has some non-rectangular UI elements. Currently, I'm subclassing UIView, and in drawRect I'm using a CGPathRef to draw black border and a color-filled interior. I'd like to make these items look more like "buttons", though, so I'd like to have some of the same sort of "glass effects" that ar...

How to move/drag multiple images with CALayer???

I have more than 10 images in screen and i want to move each image using CALayer concept. While am trying to move first image,its working. Even when i drag my second image also, its working. But after that when i get back to first image and when i try to move , am struck up. its not working. I dono where it went wrong. Here's ma code /...

What causes this error? "CALayer position contains NaN: [240 nan]"

I've seen this happen whenever i rotate a screen that has a UITableView on it. I've found out that it happens inbetween the willRotate and didRotate method calls in UIViewController My co-workers have seen it in other spots as well, usually around rotation. It hadnt started happening until very recently, and we're stumped as to how we ...

CALayer: callback when animation ends?

Hi All, I have been running into some issues with animating multiple CALayers at the same time, and was hoping someone could point me in the right direction. My app contains an array of CALayer. The position of each layer is set to (previousLayer.position.y + previousLayer.bounds.height), which basically lays them out similar to a tabl...

Animate CALayer scale without blurring

I have a CALayer that implements drawInContext: and draws a simple circle, like so: - (void)drawInContext:(CGContextRef)ctx { CGContextScaleCTM(ctx, DrawingScale, DrawingScale); CGContextSetRGBFillColor (ctx, 1, 0, 0, 1); CGContextFillEllipseInRect (ctx, LocationRectangle); } I have been experimenting with different way...

CABasicAnimation animates everything when it should only animate one thing

I made a bunch of little individual pictures, each with a separate CALayer, and they're supposed to fade in and out asynchronously at different rates. Each has a background sublayer and a fill sublayer. A timer runs in the background to animate each one individually at specific moments. For the current behavior of the program, rather ...

How to delete CALayer objects properly

For the problem I described in http://stackoverflow.com/questions/3089651/cabasicanimation-animates-everything-when-it-should-only-animate-one-thing I also need to be able to clear all of the layers and draw new ones. I tried looping through all of them and removing all of the sub layers and then the parent layers, but it either didn't...

Scale a CALayer to base unit size

My app relies heavily on Core Animation; the main view contains dozens of CALayers. In order to facilitate zooming in/out, I have a master layer which contains all layers that I wish to be 'zoomable'. When I zoom, simply modify the sublayerTransform of the master layer. This works fine, however I would like the actual content rendered b...

Unable to disable animation of CALayer>>removeFromSuperlayer

I wish to remove a CALayer from its superlayer without animating. What happens here is the layer animates to a position, works great, when however the animation stopped, this code is executed, which returns the layer to its start position, and fades out; presumably then gets removed from the superlayer. How may it be stopped from animati...

Is is possible to add a layer to a UITableView on the iPhone?

I've been trying to add a simple layer to my UITableView and it seems that the layer is drawn over the tableview components. So, is possible to put a layer under the table components or the only way would be to put the tableview into a some kind of view? ...

How to reduce the duration of an implicit animation to 0 for a CAReplicatorLayer

I've got a CAReplicatorLayer replicating its sublayer as per expected, but there's a built-in duration to the animation that I want to turn off. In other words I want to see the instantaneous results of replicating the base layer, rather than over the time duration that's implicitly specified by Apple. Here's the replication code, brack...

Can a CGImage be added to the contents property of a CAShapeLayer?

I have a custom view with a layerClass override like: + (Class) layerClass { return [CAShapeLayer class]; } I want to be able to add a CGImage to the contents property like so: - (void) animateView { UIImage *layerImage = ...; CAShapeLayer *layer = (CAShapeLayer *)self.layer; layer.contents = layerImage.CGImage; ...

CALayer valueForKey:

Hi, How different is the behavior of CALayer's valueForKey from that of any other ordinary NSObject's? I have a custom layer which inherits from CALayer, and that has a property named 'angle', but [myLayer valueForKey: @"angle"] always returns nil while [myLayer angle] returns the right value. ValueForKey: works as intended with a class ...

Setting a rotation transformation to a UIView or its layer doesn't seem to work?

I'm trying to have one of the children views in my screen (owned by one view controller) not rotate when the device rotates. My view controller allows rotations as it should, and I'm trying to apply a 90-degree rotation to the one "stationary" view to counteract the overall rotation. Problem is, everything seems to rotate anyways, and t...

CALayer performance vs. UIImageView performance

I'm noticing that some of the things that I do with images in my app, I could be doing with CALayer properties instead (i.e. borders, shadows, gradients, and so on). So I'm wondering, in general, is it a better idea to use CALayers and such, or just do all that stuff in photoshop and use UIImage(View)s for whatever I need? Scrolling perf...

animating a custom CALayer property

Hi, I'm trying to define an abstract layer property, angle, based on the existing layer property position. Basically it describes the orientation of the layer from the center of a circle. I did like the following: @interface MenuItemLayer : CALayer @property CGFloat angle; @end @implementation MenuItemLayer + (BOOL)needsDisplayForKe...

[iPhone] Analyzing NSZombie

I keep getting bad instruction or bad exception so I enabled NSZombieEnabled and the other vars needed, and I have no idea how to analyze the results. This is what was logged: ToDoWall(1634) malloc: recording malloc stacks to disk using standard recorder ToDoWall(1634) malloc: stack logging compaction turned off; size of log files on d...