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
21
votes
1 answer

How to add Stretchable UIImage in the CALayer.contents?

I have a CALayer and I want to add to it a stretchable image. If I just do: _layer.contents = (id)[[UIImage imageNamed:@"grayTrim.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0.0, 15.0, 0.0, 15.0)].CGImage; it won't work since the…
Horatiu Paraschiv
  • 1,750
  • 2
  • 15
  • 37
21
votes
6 answers

adding black overlay with 0.3 opacity over UIImageView

I have a UIImageView and I wanted to add a black overlay on top of it. What is the best way of doing this without having to override drawRect? I was thinking of adding a CALayer on top of it. But unsure how to get a black CALayer with a .3 alpha.
xonegirlz
  • 8,889
  • 19
  • 69
  • 127
21
votes
1 answer

How to apply CAGradientLayer as mask of another CALayer?

I have a view, which has a CALayer. When I create a CAGradientLayer and apply it as the mask of that view's CALayer, nothing happens. Why? In -initWithFrame: of the view I do this: CAGradientLayer *gradient = [CAGradientLayer layer]; gradient.frame…
Proud Member
  • 40,078
  • 47
  • 146
  • 231
20
votes
4 answers

How to add a CALayer to an NSView on Mac OS X

I'm trying to learn how to use and implement CALayer in a Mac Objective-C application, but I can't seem to probably do the most basic thing - add a new layer and set its background colour/frame size. Can anyone see what is wrong with my…
GravityScore
  • 385
  • 1
  • 3
  • 13
20
votes
2 answers

Core Animation CALayer mask animation performance

We wanted to use a UITabBar in our iPhone app, but with one exception: we have a "sync" button which I wanted to rotate while the sync operation is happening. Unfortunately this meant having to create a custom tab bar, but that's neither here nor…
Brent Dillingham
  • 1,019
  • 1
  • 13
  • 22
20
votes
9 answers

layer is a part of cycle in its layer tree iOS 9 Swift 2

When I load my view controller I'm getting this error: *** Terminating app due to uncaught exception 'CALayerInvalid', reason: 'layer is a part of cycle in its layer tree' I don't know why. I think I might've added a third…
Brie
  • 441
  • 1
  • 6
  • 14
20
votes
3 answers

Need better and simpler understanding of CATransform3D

Please go through the images. So this is the code which I got from some online source and it does transform my object. Besides that, I understood nothing at all. I am new to CATransform3D and want to know exactly how it works. CATransform3D…
mayuur
  • 4,736
  • 4
  • 30
  • 65
20
votes
3 answers

CABasicAnimation with CALayer path doesn't animate

I'm trying to animation the transition of a CALayer from normal corners to rounded corners. I only want to round the top corners, so I am using a UIBezierPath. Here's the code: UIRectCorner corners = UIRectCornerTopLeft |…
eric.mitchell
  • 8,817
  • 12
  • 54
  • 92
19
votes
1 answer

How do you animate the sublayers of the layer of a UIView during a UIView animation?

In a UIView animation for a view, you can animate its subviews being laid out by including UIViewAnimationOptionLayoutSubviews in the options parameter of [UIView animateWithDuration:delay:options:animations:completion:]. However, I cannot find a…
ememem
  • 968
  • 1
  • 10
  • 23
19
votes
1 answer

CALayer Antialiasing not as good as UIView antialiasing

I've been trying to animate circle drawing using CALayer. It all works well, but the problem is - drawn circle is not antialiased enough. It has a bit too rough borders, (or blurred if rasterize is used). (AntiAliasing is enabled) Tried…
Guntis Treulands
  • 4,764
  • 2
  • 50
  • 72
19
votes
7 answers

AVCaptureVideoPreviewLayer landscape orientation

How can I get 'AVCaptureVideoPreviewLayer' to display properly in landscape orientation? It works fine in portrait but doesn't rotate, and shows a rotated camera capture when the parent view controller is in landscape orientation.
Ege Akpinar
  • 3,266
  • 1
  • 23
  • 29
19
votes
7 answers

iOS: Rounded rectangle with border bleeds color

I'm drawing round avatar pics, by just applying cornerRadius to a UIImageView's layer, and also adding a border via borderWith and borderColor. Like so: self.layer.masksToBounds = YES; self.layer.cornerRadius = imageDimension /…
manmal
  • 3,900
  • 2
  • 30
  • 42
19
votes
5 answers

UICollectionViewCell with rounded corners AND drop shadow not working

I want my UICollectionViewCells to have rounded corners and drop shadows but I have run into a problem where it seems I can only have one or the other, but not both. To just round the corners I use this code in the initialization of the…
jj0b
  • 1,106
  • 1
  • 12
  • 19
19
votes
6 answers

How to draw CALayer border around its mask?

So, I have a CALayer, which has a mask & I want to add border around this layer's mask. For example, I have set triangle mask to the layer and I want to have border around that layer. Can anyone please help me to solve this problem?
Fahri Azimov
  • 11,470
  • 2
  • 21
  • 29
19
votes
1 answer

What's the magic behind CAReplicatorLayer?

What I find interesting with CAReplicatorLayer: It is able to display a CALayer multiple times with different transforms very efficiently (how?) It seems like it somehow reuses the "backing store" for the replicated layer and even apply some color…
hfossli
  • 22,616
  • 10
  • 116
  • 130