Questions tagged [calayer]

CALayer is a Core Animation class in the Quartz Core framework. It encapsulates the geometry and presentation of a layer. It supports animations of the layer's geometry and its content.

The layer classes are the foundation of Core Animation and provide an abstraction that should be familiar to developers who have used NSView or UIView. Basic layer functionality is provided by the CALayer class, which is the parent class for all types of Core Animation layers.

The CALayer class is the model class for layer-tree objects. It encapsulates the position, size, and transform of a layer, which defines its coordinate system. It also encapsulates the duration and pacing of a layer and its animations by adopting the CAMediaTiming protocol, which defines a layer’s time space.

2853 questions
24
votes
2 answers

CALayer animates with frame change?

I have a CALayer I've added to my view: myView.myCALayer = [[CALayer alloc] init]; CGSize size = myView.frame.size; myView.myCALayer.frame = CGRectMake(0, 0, size.width, size.height); myView.myCALayer.backgroundColor = [[UIColor blackColor]…
mark
  • 1,398
  • 13
  • 30
23
votes
2 answers

Performance Issues When Using Many CALayer Masks

I am trying to use CAShapeLayer to mask a CALayer in my iOS app as it takes a fraction of the CPU time to mask an image vs manually masking one in a bitmap context; When I have several dozen or more images layered over each other, the CAShapeLayer…
daveMac
  • 3,041
  • 3
  • 34
  • 59
23
votes
2 answers

Best way to mirror a UIWebView

I need to mirror a UIWebView's CALayers to a smaller CALayer. The smaller CALayer is essentially a pip of the larger UIWebView. I'm having difficulty in doing this. The only thing that comes close is CAReplicatorLayer, but given the original and the…
Luke
  • 13,678
  • 7
  • 45
  • 79
23
votes
2 answers

On iOS, drawRect cannot draw outside of the view's bounds?

I thought from some point on for OS X, and always true for iOS, that content can appear outside of the view's bounds? (for UIView) But if I create a brand new Single View app, and created a MyView class that subclasses UIView, and implement its…
nonopolarity
  • 146,324
  • 131
  • 460
  • 740
22
votes
1 answer

Iphone How to make context background transparent?

CALayer *sublayer = [CALayer layer]; /*sublayer.backgroundColor = [UIColor blueColor].CGColor; sublayer.shadowOffset = CGSizeMake(0, 3); sublayer.shadowRadius = 5.0; sublayer.shadowColor = [UIColor blackColor].CGColor; sublayer.shadowOpacity =…
MegaManX
  • 8,766
  • 12
  • 51
  • 83
22
votes
3 answers

iOS drawing in CALayers drawInContext is either pixelated or blurry on retina

I have a custom UIView that draws something in an overwritten - (void)drawRect:(CGRect)rect this works fine and gives sharp results on retina screens. However, now I would like to make the properties on which the drawing is based animatable.…
matthias_buehlmann
  • 4,641
  • 6
  • 34
  • 76
22
votes
6 answers

How can I add shadow to a circle UIImageView or UIView?

I am trying to make a circle UIImageView, and it works. Below is the way I use to make it: [self.pic.layer setMasksToBounds:YES]; [self.pic.layer setCornerRadius:50.0]; I would like to add some shadow to the UIImageView. The below code does add…
Newbie
  • 2,775
  • 6
  • 33
  • 40
22
votes
3 answers

Scale UIView with the top center as the anchor point?

I'm scaling a UIView with CGAffineTransformMakeScale but I want to keep it anchored to it's current top center point as it's scaled. I've looked into setting view.layer.anchorPoint but I believe I need to use this in conjunction with setting…
Alistair Holt
  • 1,432
  • 3
  • 17
  • 28
21
votes
10 answers

CoreAnimation - Opacity Fade In and Out Animation Not Working

I'm attempting to create a fairly simple CoreAnimation for use in an AVComposition. My goal is to create a CALayer which, through various sublayers, fades a title in and out, then fades in an out images. A slideshow, basically. This is being…
21
votes
2 answers

How can I know the values in CABasicAnimation keyPath

I find some code like this: CABasicAnimation *anim = [CABasicAnimation animation]; anim.keyPath = @"transform.scale"; anim.fromValue = [NSNumber numberWithFloat:1.0]; anim.toValue = [NSNumber numberWithFloat:0]; anim.removedOnCompletion =…
Sailing
  • 337
  • 1
  • 2
  • 9
21
votes
3 answers

CATransform3D rotate causes half of image to disappear

I'm using the following code to rotate an image, but half the image (down the y-axis) that has been rotated "out of" the page, disappears. How to fix? heading is in radians. CALayer *layer = myUIImageView.layer; CATransform3D…
iPadDeveloper2011
  • 4,560
  • 1
  • 25
  • 36
21
votes
5 answers

CALayer autoresizing on iPhone/iPad: How?

I'm trying to create a UIView subclass ("GradientView") that will fill itself with a gradient of various colors. I've implemented it by adding a CAGradientLayer as a sub-layer of UIView's layer. It looked good, but when the screen was rotated, it…
Moduspwnens
  • 525
  • 1
  • 5
  • 9
21
votes
1 answer

Adding CIFilter to CALayer under Mavericks?

so this is the standard way of adding filter to a layer: NSView *view = self.window.contentView; view.wantsLayer = YES; CATextLayer *textLayer = [CATextLayer layer]; textLayer.frame = CGRectMake(10.0, 10.0, 200.0, 100.0); textLayer.string =…
Vojto
  • 6,901
  • 4
  • 27
  • 33
21
votes
2 answers

Infinite CABasicAnimation stops

I 've an infinite animation (rotating an image, type: CABasicAnimation) in my UIView with animation.repeatCount = HUGE_VALF; When I push a new ViewController and go back to the initial ViewController with the animation containing View inside, the…
pinki
  • 902
  • 2
  • 12
  • 29
21
votes
2 answers

CALayer opacity animation

I want to create a CALayer animation that gives sort of a 'flashy' effect. For that I'm trying to animate the 'opacity' property, but my problem is that I have no idea where to start and how to do it. Here is a graphical explanation of the…
Alex
  • 5,009
  • 3
  • 39
  • 73