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
32
votes
3 answers

When do I need to set the contentsScale property of a CALayer?

In the documentation Apple states that you need to consider the scale factor of a layer when it: Creates additional Core Animation layers with different scale factors and composites them into its own content Sets the contents property of a Core…
Andrea
  • 26,120
  • 10
  • 85
  • 131
32
votes
3 answers

Shadow not showing when background color is clear color

I've created an uiview in my xib with background color as clear color. When I apply the shadow on the layer of the view, the shadow is not appearing. But when i set the background color other than clear color, shadow is showing. Please help. this is…
Mukunda
  • 389
  • 1
  • 3
  • 9
31
votes
2 answers

Center custom UIView vertically and horizontally using Auto Layout

I'm trying to build a rather simple animated custom UI using the Auto Layout API newly available iOS 6. The custom view I'm building has a circle that I want to be both vertically and horizontally centered. Unfortunately I can't figure out why my…
phor2
  • 637
  • 2
  • 6
  • 12
30
votes
9 answers

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…
Alex Repty
  • 1,060
  • 1
  • 9
  • 17
30
votes
3 answers

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…
jemmons
  • 18,605
  • 8
  • 55
  • 84
29
votes
4 answers

SpringWithDamping for CALayer animations?

After playing around a lot with the UIView dynamic animations introduced in iOS 7, most notably: [UIView animateWithDuration: delay: usingSpringWithDamping: initialSpringVelocity: options: animations: completion:]; I was wondering if there is an…
Sarreph
  • 1,986
  • 2
  • 19
  • 41
29
votes
2 answers

CALayer - Place sublayer below storyboard UIButtons?

I've got a view controller in my storyboard with several UIButtons. One of them activates an AVFoundation camera preview layer shown in a sublayer: captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc]…
golmschenk
  • 11,736
  • 20
  • 78
  • 137
29
votes
3 answers

Observing animated property changes in a CALayer

I have a CABasicAnimation that animating a property of a CALayer e.g. bounds.origin. I want to be able to observe the property changing over time, but haven't really found a method that works 100%. I tried using KVO (key-value observation) on the…
Glen Low
  • 4,379
  • 1
  • 30
  • 36
28
votes
3 answers

CAGradientLayer diagonal gradient

I use the following CAGradientLayer: let layer = CAGradientLayer() layer.colors = [ UIColor.redColor().CGColor, UIColor.greenColor().CGColor, UIColor.blueColor().CGColor ] layer.startPoint = CGPointMake(0, 1) layer.endPoint =…
Evgeny
  • 631
  • 6
  • 17
28
votes
4 answers

How to draw radial gradients in a CALayer?

I know CAGradientLayer doesn't support radial gradient at the moment and only has option of kCAGradientLayerAxial. I want something like below: I have looked around for this issue and found that there is a way around this. But the explanations were…
blancos
  • 1,576
  • 2
  • 16
  • 38
26
votes
1 answer

How to Animate a UIBezierPath

i would like to animate a UIBezierPath of a rect to a triangle one, not to animate a view on a path but animate the path itself so it morphs from one shape to another. the path is added to a CALayer CAShapeLayer *maskLayer = [CAShapeLayer…
Yogev Shelly
  • 1,373
  • 2
  • 13
  • 24
25
votes
6 answers

Make NSView NOT clip subviews outside of its bounds

Is it possible to make an NSView not clip its subviews that are outside of the bounds? On iOS I would simply set clipsToBounds of my UIView no NO. But NSView doesn't have such a property. I tried experimenting with wantsLayer, masksToBounds,…
DrummerB
  • 39,814
  • 12
  • 105
  • 142
24
votes
1 answer

Scale the size of CALayer contents

I have a few UIImageViews inside CALayer. How do I scale them all at once? I did try setting CALayer properties like la.contentsGravity = @"kCAGravityResizeAspect"; but the images inside the layer always display the original size.
Registered User
  • 3,669
  • 11
  • 41
  • 65
24
votes
4 answers

How to get touch event on a CALayer?

I'm new to the iPhone SDK. Right now I'm programming with CALayers which I really like a lot – not as expensive as UIViews, and a lot less code than OpenGL ES sprites. I have this question: is it possible to get a touch event on a CALayer? I…
Alex Lowe
24
votes
1 answer

How to render view into image faster?

I'm making magnifier app, which allows an user touch the screen and move his finger, there will be a magnifier with his finger path. I implement it with take a screenshot and assign the image to magnifier image view, as following: CGSize…
NOrder
  • 2,483
  • 5
  • 26
  • 44