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
83
votes
8 answers

Auto Layout constraint on CALayer IOS

Hi I am developing iPhone application in which I tried to set one side border for edittext. I did this in following way: int borderWidth = 1; CALayer *leftBorder = [CALayer layer]; leftBorder.borderColor = [UIColor…
nilkash
  • 7,408
  • 32
  • 99
  • 176
83
votes
5 answers

How do you move a CALayer instantly (without animation)

I'm trying to drag a CALayer in an iOS app. As soon as I change its position property it tries to animate to the new position and flickers all over the place: layer.position = CGPointMake(x, y) How can I move CALayers instantly? I can't seem to…
Mel
  • 2,269
  • 1
  • 18
  • 18
80
votes
5 answers

How to draw a smooth circle with CAShapeLayer and UIBezierPath?

I am attempting to draw a stroked circle by using a CAShapeLayer and setting a circular path on it. However, this method is consistently less accurate when rendered to the screen than using borderRadius or drawing the path in a CGContextRef…
bcherry
  • 7,150
  • 2
  • 28
  • 37
76
votes
5 answers

UIView animation vs CALayers

I'm struggling with conceptualizing animations with a CALayer as opposed to UIView's own animation methods. Throw "Core Animation" into this and, well, maybe someone can articulate these concepts from a high level so I can better visualize what's…
Meltemi
  • 37,979
  • 50
  • 195
  • 293
72
votes
3 answers

How is the relation between UIView's clipsToBounds and CALayer's masksToBounds?

A UIView has a CALayer. That's pretty sure. But both seem to provide something that means the same thing. If I'd set clipsToBounds=YES, would this also set the layer's masksToBounds=YES? Why different names? Anyone knows?
Thanks
  • 40,109
  • 71
  • 208
  • 322
65
votes
7 answers

CALayer: add a border only at one side

I can add a border to a CALayer in this way: [webView.layer setBorderColor: [[UIColor colorWithRed:0.6 green:0.7 blue:0.2 alpha:1] CGColor]]; [webView.layer setBorderWidth: 2.75]; But is it possible to add a border only at one side? I only need…
Manni
  • 11,108
  • 15
  • 49
  • 67
65
votes
8 answers

remove all subLayers from a view

In an animation I added a lot of sublayers to a view, with: [self.view.layer addSublayer:layer1]; [self.view.layer addSublayer:layer2]; .... I would like to remove all sublayers with an action. I already tried with this suggestion of a similar…
Beppino66
  • 1,709
  • 2
  • 13
  • 15
62
votes
13 answers

AVPlayer layer inside a view does not resize when UIView frame changes

I have a UIView which contains an AVPlayer to show a video. When changing orientation, I need to change the size and location of the video. I'm not very experienced with resizing layers, so I'm having problems making the video resize. I start by…
theDuncs
  • 4,649
  • 4
  • 39
  • 63
60
votes
12 answers

How to disable CALayer implicit animations?

It's driving me crazy! I am working on a drawing application. Let's say I am working on a UIView called sheet. I am adding some sublayers to this view ([sheet.layer addSublayer:...]) and then I want to draw into them. To do so I am creating a…
Esepher
  • 641
  • 1
  • 5
  • 4
57
votes
1 answer

What's the difference and compatibility of CGLayer and CALayer?

I'm confusing CGLayer and CALayer. They look similar, so why are there separate implementations? What's the difference between, and compatibility of, CGLayer and CALayer?
eonil
  • 83,476
  • 81
  • 317
  • 516
57
votes
1 answer

Layer-backed NSView rotation and skewed siblings

I have a strange issue with layer-backed NSView and it's siblings, some of them are not rendered correctly when added into the existing view hierarchy attached to the rotated superview. Below are the details. The problem - NSScrollView (layer can be…
Gobra
  • 4,263
  • 2
  • 15
  • 20
55
votes
7 answers

add UIImage in CALayer

I must add a UIImageView as subview of MapView. To do this I created a layer above the MapView. In this layer I want to put my image, but I get a white rectangle and nothing else. My image is not visible. This is the code: - (void)viewDidLoad { …
Ortensia C.
  • 4,666
  • 11
  • 43
  • 70
51
votes
1 answer

CABasicAnimation does not animate correctly when I update model layer

I'm currently implementing a CABasicAnimation that animates a CALayer transform property. Now, although I'm new to Core Animation, I have been able to gather through various blogs and articles such as objc.io that it is a very bad idea to use the…
user3546182
  • 565
  • 5
  • 6
48
votes
8 answers

iOS - How To Remove Previously Added Sublayers Of a UIView

I have a custom view which is a subclass of UIView. I added some sublayers to the custom view but now I want remove them. I tried doing this: self.layer.sublayers = nil; But this will remove everything including the initial sublayers of the…
JLT
  • 3,052
  • 9
  • 39
  • 86
48
votes
7 answers

What causes this error? "CALayer position contains NaN: [240 nan]"

I've seen this happen whenever i rotate a screen that has a UITableView on it. I've found out that it happens inbetween the willRotate and didRotate method calls in UIViewController My co-workers have seen it in other spots as well, usually around…
Kevlar
  • 8,804
  • 9
  • 55
  • 81