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
46
votes
4 answers

UILabel layer cornerRadius negatively impacting performance

I've created a document view which displays the page number in the corner. The page number is a uilabel with a semi-transparent background colour, and has a corner radius (using the cornerRadius property of the view's layer). I've positioned this…
Nick
  • 3,958
  • 4
  • 32
  • 47
45
votes
1 answer

How to do transforms on a CALayer?

Before writing this question, I've had experience with Affine transforms for views read the Transforms documentation in the Quartz 2D Programming Guide seen this detailed CALayer tutorial downloaded and run the LayerPlayer project from…
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
43
votes
4 answers

UIImage from CALayer in iOS

In my application, I have created a CALayer (with a few sublayers - the CALayer is composed of shapes added as sublayers). I am trying to create a UIImage that I will be able to upload to a server (I have the code for this). However, I can't figure…
Brett
  • 11,637
  • 34
  • 127
  • 213
43
votes
4 answers

Subview appears underneath superviews layer.border?

I have a UIView in which I define it's border in the following manner: self.layer.borderColor = [UIColor blackColor].CGColor; self.layer.borderWidth = 3; I attach a subview to this UIView, and when I move the subview over the border, it goes…
Ser Pounce
  • 14,196
  • 18
  • 84
  • 169
40
votes
8 answers

iOS Core Animation: CALayer bringSublayerToFront?

How do I bring a CALayer sublayer to the front of all sublayers, analogous to -[UIView bringSubviewToFront]?
ma11hew28
  • 121,420
  • 116
  • 450
  • 651
40
votes
3 answers

After rotating a CALayer using CABasicAnimation the layer jumps back to it's unrotated position

I am trying to create a falling coin. The coin image is a CALayer with 2 CABasicAnimations on it - a falling down and a rotation one. When the falling down animation gets to its end, it stays there. The rotation animation though, which is supposed…
Mikle
  • 1,842
  • 4
  • 20
  • 32
36
votes
6 answers

CALayer - Shadow causes a performance hit?

So I am doing some custom animations on my navigationcontroller and the way it pushes and pops the viewControllers. Everything runs smooth. As soon as I add the following code (In a subclass of UINavigationController), I face a huge performance hit.…
aryaxt
  • 76,198
  • 92
  • 293
  • 442
36
votes
8 answers

Using CALayer Delegate

I have a UIView whose layers will have sublayers. I'd like to assign delegates for each of those sublayers, so the delegate method can tell the layer what to draw. My question is: What should I provide as CALayer's delegate? The documentation…
Shaun Budhram
  • 3,690
  • 4
  • 30
  • 41
36
votes
9 answers

UIView with a Dashed line

What I have: To create this line, I basically have an UIView and I do the following: void setLayerToLineFromAToB(CALayer *layer, CGPoint a, CGPoint b, CGFloat lineWidth) { CGPoint center = { 0.5 * (a.x + b.x), 0.5 * (a.y + b.y) }; CGFloat…
Rui Peres
  • 25,741
  • 9
  • 87
  • 137
35
votes
5 answers

Tagging CALayers in iPhone

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…
Peyman
  • 1,058
  • 1
  • 14
  • 27
35
votes
5 answers

Drop a shadow to right and bottom of uiview

I have to drop a shadow to the right and bottom of uiview.Im doing this in interface builder.But I see the shadow dropped to top of it.Tried differnt sizes.but couldn't get…
Honey
  • 2,840
  • 11
  • 37
  • 71
35
votes
4 answers

Animate CALayer border change

I'm setting a border width and color to a UIView subclass this way: - (void) setViewBorder { self.layer.borderColor = [UIColor greenColor].CGColor; self.layer.borderWidth = 3.0f; } My question is: How can I animate this? Thanks.
iOS Dev
  • 4,143
  • 5
  • 30
  • 58
34
votes
4 answers

UIButton with GradientLayer obscures image and darkens gradient

I have an UIButton here where I'd like to have a gradient as the background below the image (symbol with transparent background), but I'm facing two different problems. First of the CAGradientLayer seems to overlay on top of the image no matter how…
Christian A. Strømmen
  • 3,181
  • 2
  • 25
  • 46
33
votes
5 answers

Rotating a CALayer 90 degrees?

How do I rotate a CALayer 90 degrees? I need to rotate everything include sublayers and the coordinate system.
Kristina
  • 15,859
  • 29
  • 111
  • 181
33
votes
2 answers

Stop CALayer shadow from affecting subviews?

I have a custom UIControl, and I want it to have a shadow, so I set the relevant properties on its layer. A shadow appears around the view as desired, but a shadow also appears under the text of a UILabel, which is a subview. How do you stop this?…
Rob N
  • 15,024
  • 17
  • 92
  • 165