calayer

How do i rotate a CALayer around a diagonal line?

Hi. I'm trying to implement a flip animation to be used in board game like iPhone-application. The animation is supposed to look like a game piece that rotates and changes to the color of its back (kind of like an Reversi piece). I've managed to create an animation that flips the piece around its orthogonal axis, but when I try to flip i...

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 "animatable" properties (bounds, position, etc). Is there something I can override to make my custom myInt property animatable? ...

Wrapping/warping a CALayer/UIView (or OpenGL) in 3D (iPhone)

I've got a UIView (and thus a CALayer) which I'm trying to warp or bend slightly in 3D space. That is, imagine my UIView is a flat label which I want to partially wrap around a beer bottle (not 360 degrees around, just on one "side"). I figured this would be possible by applying a transform to the view's layer, but as far as I can tell,...

Nested CALayers not picking up perspective tranform

Hi, I'm trying to make use of CALayers to create a 3D style effect in one of my applications. However, it seems that nested CALayers do not have perspective applied to them. To illustrate with pseudo-code, if I have a layer with perspective applied like so: CATransform3D subLayerTransform = CATransform3DIdentity; /* set perspective */...

How to draw the bitmap of one layerA into the bitmap of layerB?

I have two CALayer objects. layerA and layerB. I want to copy the bitmap from layerA over to layerB, so that layerB has the "same" bitmap (that looks the same). How could I do that without using UIImage and the like inbetween? ...

Animate a GIF using Core Animation layers?

I'm trying to animate a GIF and I hit a roadblock. I have an example of what I'm trying to do that uses the individual frames of the GIF and setting the animationImages property of a UIView. However in my project, the thing I want to animate is drawn using Layers. I'm looking for a quick and easy way to animate the frames without introdu...

CALayers didn't get resized on its UIView's bounds change. Why?

I have a UIView which has about 8 different CALayer sublayers added to its layer. If I modify the view's bounds (animated), then the view itself gets shrinked (I checked it with a backgroundColor), but the sublayers' size remains unchanged. How to solve this? I've just started googleing but haven't found any useful. Thanks in advance. ...

CALayer won't display

I'm trying to learn how to use CALayers for a project and am having trouble getting sublayers to display. I created a vanilla View-based iPhone app in XCode for these tests. The only real code is in the ViewController which sets up the layers and their delegates. There is a delegate, DelegateMainView, for the viewController's view lay...

How to tile the contents of a CALayer?

I would like to tile a CGImage across a CALayer, but it seems to only want to stretch it. The example code: self.background = [UIImage imageNamed: @"Background.png"]; [documentDisplay.layer setContents: self.background.CGImage]; I would like to avoid subclassing if I could. ...

Using a CALayer in UITableViewCell

On each cell of my table view I want to have a bar that the user can slide out from the right. On the bar I plan to have icons. So, to do this I subclassed UITableViewCell. On the cell I have implemented drawRect and in there I have already drawn a gradient and background color on the cell. From there, I can create a CALayer, give it...

CALayer and Quartz Transparency

I have a CALayer subclass. I have overridden the drawInContext method. I want the majority of my layer to be transparent except a few areas. I'm using the layer as a menu and I want the icons and labels on the menu to be opaque. Is it possible to have a CALayer's sublayers be opaque if the super CALayer is transparent? Is it possi...

Creating a custom animation with CGLayers?

Basically, I want to animate a shrinking circle. I've already done this by drawing progressively smaller circles onto CGLayer's, and then using if(index < 30){ [self performSelector:@selector(showNextLayer) withObject:nil afterDelay:(NSTimeInterval)0.02]; index++; } in my showNextLayer method. This works for my simple goal, but in ge...

How to transform (rotate) a already exist CALayer/animation?

Hello, I have added a CALayer to the UIView of my app: CATransition *animation = [CATransition animation]; [animation setDelegate:self]; [animation setDuration:0.35]; [animation setTimingFunction:UIViewAnimationCurveEaseInOut]; animation.type = @"pageCurl"; animation.fillMode = kCAFillModeForwards; ...

Why can I not add a animation to a UIImageView?

Hello, Im trying to add a animation to a UIImageView, but it always fails. Why? Here is the code: //(…) UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); animationImage = [[UIImageView alloc]initWithImage:newImage]; [self.view addSubview:animationImage]; CATransition *animation...

iPhone CALayer Stacking Order

I'm using CALayers to draw to a UITableViewCell. I'm trying to figure out how layers are ordered with the content of the UITableViewCell. For instance: I add labels to the UITableViewCell in my cellForRow:atIndexPath method In the drawRect method of UITableViewCell I draw some content using the current context Also, in drawRect I add...

What class should manage/control the CALayers in my view using proper MVC?

I have a ViewController with a view (UIView). I need to handle touches, run some logic, check against model data, and and add and remove sublayers to the view based on those touches. Then I need to update the model based on the results. Should I have: ViewController - manage touches, get/set model data, add/remove sublayers UIView ...

iPhone Dev:Blurring of CALayers when rotated

Hello All, I have a CALayer with a png image as its content.When rotation is applied the layer looks blurry. I've searched for a cause for this problem and found out that the problem might be the half pixel problem, which makes the layer blurry if its frame.origin lays on fractions like 96.5, and they suggest to make the origin a whol...

iPhone: CALayer Memory Leak question

Would the code bellow cause my code to leak? More specifically, am I responsible for releasing the newImage or the contents of mainPageLayer (which is a CALayer object)? I get a memory warning every 4th time that method is called, but cant figure out why... I also can't figure out why mainPageLayer.contents = [newImage CGImage]; throws ...

Drawing and Animating with UIView or CALayer?

hello, i am trying to implement a graph which a uiview draws. There are 3 UIViews to animate a left/right slide. The problem is, that i can't cancel the UIView animation. So I replaced the UIViews by CALayer. Now, the question is if CALayer is appicable for this? Is it normal to draw on a CALayer like this? And why is a CALayer so slow w...

Multiple CALayer performance issue

Hello all, I'm currently facing some performance issues, when using several custom layers as sublayers inside my view. After creating my new layer programmatically, I add it as sublayer, like: [self.view.layer addSublayer:myNewSublayer]; This works just fine. However, when doing this over and over my app starts to slow down more an...