calayer

CAKeyframeAnimation - Examples

I have a a menu that is a CALayer that will slide across the screen to a given point. I want the effect where the menu will go a little past the point, then a little before the point, and then land on the point. I can move the menu by applying a transform, but I was hoping to get this bouncing effect to work. I was looking into CAKeyf...

Issue with CAAnimation and CALayer Transforms

I have a CALayer that I want to animate across the screen. I have created two methods: one slide open the layer and one to slide close. These both work by assigning a property to the layer's transform property. Now I want to use a CAKeyFrameAnimation to slide open the layer. I got this working so the layer slides open, but now I can'...

[CA_COLOR_OPAQUE] things that make a layer non-opaque. scaled CAGradientLayer?

i spent some time with the environment variable CA_COLOR_OPAQUE = 1 and have my findings to share. things that make a CALayer non-opaque (slow, more memory, ...): * contents with alpha (like an NSImage with an icon) * NSImage/CGImage from a pdf as contents (even when the pdf does not contain any alpha and opaque=YES) * b...

Darkening a UIView

I'd like to "darken" a UIView by a certain amount. Right now, I'm doing the darkening like this: UIView *overlay = [[UIView alloc] initWithFrame:mainView.bounds]; overlay.backgroundColor = [UIColor blackColor]; overlay.alpha = 0.5f; [mainView addSubview:overlay]; Unfortunately, this also adds a semi-transparent black overlay to parts ...

iPhone: CALayer + rotate in 3D + antialias?

Hi all, An iPhone SDK question: I'm drawing a UIImageView on the screen. I've rotated it in 3D and provided a bit of perspective, so the image looks like it's pointing into the screen at an angle. That all works fine. Now the problem is the edges of the resulting picture don't seem to be antialiased at all. Anybody know how to make it s...

iPhone - Jagged Edges when applying perspective to CALayer

I have a CALayer that I apply a perspective to using a CGTransform3D and specifying the m14 property. When the perspective is applied, the layer has jagged edges. I've heard people mention that adding a 1px transparent border around the layer will help with this. I don't know how to do that. I have tried using the border and borderWi...

UIButton not firing selector if I draw it using CALayer

Hi everybody I create this button like this: _myButton = [[UIButton buttonWithType:UIButtonTypeCustom] retain]; DLBadgeLayerDelegate *layerDelegate = [[DLBadgeLayerDelegate alloc] init]; _myButton.frame = CGRectMake(0.0 , 0.0, 100.0, 100.0); [_myButton addTarget:self action:@selector(myButtonTapped:) forControlEvents:UICon...

Is it possible to mask CALayer in iPhone?

I'm trying to mask CALayer with a bitmap image. And I failed masking CALayer. My code is: // 'PreloadViewController layerWithImageNamed' create a layer and set it's contents as specified UIImage. CALayer* title = [PreloadViewController layerWithImageNamed:@"pinkhug_txt.png"]; [[[self view] layer] addSublayer:title]; CALayer* title_ma...

iPhone: CATiledLayer/UIScrollView wont scroll after zooming and only zooms to anchor point

Here is the problem... I am using CA Tiled Layer to display a large jpg. The view loads okay, and when I go to scroll around, it works fine. However, as soon as I zoom in or out once, it scrolls to the top left (to the anchor point) and will not scroll at all. The zooming works fine, but I just cannot scroll. Here is my code: #import <...

Printing CALayers

I have a NSView which contains many CALayers. When a user is editing a document, these CALayers animate all edits. I am attempting to implement printing for my app, but I am having some problems printing these CALayers correctly. Some CALayers bounds occupy the entire NSView, and do not need to be laid out, because their position never ...

The best way to implement drawing features like Keynote

Hi all, I'm trying to make a little iPad tool's for drawing simple geometrical objects (rect, rounded rect, ellipse, star, ...). My goal is to make something very close to Keynote (drawing feature), i.e. let the user add a rect (for instance), resizing it and moving it. I want too the user can select many objects and move them together....

addSublayer vs addSubView which is more efficient?

I have 5 UIImageViews for displaying 5 images. For my app, I need swap the order of them depending on some events. I achieve this by calling: [anImageView1 removeFromSuperview]; [self.view insertSubview:anImageView1 aboveSubview:anImageView2]; Recently, I've come across a different method for doing this using 1 UIView and 5 UIImageVie...

How to move a line or rectangle in a context without setNeedsDisplay

I have a rather complex graphic within the context of a UIView within a UIScrollView that is created on load using CGPath and GContext path functions. The graphic is static unless the user changes one of it's parameters which in turn calls setNeedsDisplay on the UIView. The graphic is laid out over a 24 hour period and I now want to add...

Mimic CALayer shadow properties found in iPhone OS 3.2 for OS 3.1

The CALayer shadow properties like shadowOffset, shadowRadius, shadowColor are not available in iPhone OS versions below 3.2 and I'm wondering how I could mimic that functionality for use with 3.1 and below. I want to use this to be able to add drop shadows to UIViews in a clean way so that the shadows are drawn at layer level somehow, ...

Animating a CALayer with a series of repeating images

I have created CALayer objects and am able to animate their movement around the screen. However, now I want to animate them to change through a set of images in a loop to create an animation (like an animated gif) I'm fairly new to programming and very new to cocoa so code examples welcomed. I have 15 png images. --Charliehorse EDI...

Why CAAnimation Rotation is returning to previous state

I am using CAKeyFrameAnimation to do rotation of an arrow image. Problem is that the imageview is returning back to the previos state after animation. Code: CAKeyframeAnimation *rotation = [CAKeyframeAnimation animation]; rotation.duration = 0.55; rotation.cumulative = TRUE; rotation.removedOnCompletion = NO; if (isFlipRight) ...

Returning NSNull from actionForLayer:forKey

If I implement the CALayer delegate method actionForLayer:forKey I can return [NSNull null] to force the CALayer to not animate any changes. Unfortunately, [NSNull null] doesn't implement the CAAction delegate and XCode kicks out the following warning: warning: class 'NSNull' does not implement the 'CAAction' protocol Here is the m...

Tagging CALayers in iPhone

Hi I am looking for a general way to be able to search for a unique CALayer in a hierarchy without having to remember where the layer is in a hierarchy (and use the sublayer: and superlayer: methods). I know this is possible with UIViews (which makes flipping views easy) but is it possible for CALayer? thank you in advance for your ...

iPhone imageView layer masksToBound leads to slow scrolling

I have a UITableView with about 30 cells, 5 are viewable at a time. In each cell I have 2 UILabels and 1 UIImageView. I use a CALayer to render the image view with a rounded border. myImageView.layer.masksToBounds = YES; myImageView.layer.cornerRadius = 2.5; myImageView.layer.borderWidth = 1.0; myImageView.layer.border...

CALayer rotation on Y axis ignores z position

Hi, i have some CALayers one on top of the other with different z-values. the z-values are sequential (1,2,3 ...). i wrote some code that changes the y-rotation of a CALayer when i click on it. the y-rotations changes to -30.f the problem is that when i click on a CALayer it rotates and goes behind the CALayers that are actually beneat...