---
title: CAShapeLayer
framework: quartzcore
role: symbol
role_heading: Class
path: quartzcore/cashapelayer
---

# CAShapeLayer

A layer that draws a cubic Bezier spline in its coordinate space.

## Declaration

```swift
class CAShapeLayer
```

## Overview

Overview The shape is composited between the layer’s contents and its first sublayer. The shape will be drawn antialiased, and whenever possible it will be mapped into screen space before being rasterized to preserve resolution independence. However, certain kinds of image processing operations, such as CoreImage filters, applied to the layer or its ancestors may force rasterization in a local coordinate space. The following code shows how you can build complex, composite paths and display them using a shape layer. In this example, a series of progressively transformed ellipses form a simple flower shape. The shape layer that displays the path has its fillRule set to evenOdd which stops the overlapping “petals” from filling with the yellow fillColor. let width: CGFloat = 640 let height: CGFloat = 640       let shapeLayer = CAShapeLayer() shapeLayer.frame = CGRect(x: 0, y: 0,                           width: width, height: height)       let path = CGMutablePath()       stride(from: 0, to: CGFloat.pi * 2, by: CGFloat.pi / 6).forEach {     angle in      var transform  = CGAffineTransform(rotationAngle: angle)         .concatenating(CGAffineTransform(translationX: width / 2, y: height / 2))          let petal = CGPath(ellipseIn: CGRect(x: -20, y: 0, width: 40, height: 100),                        transform: &transform)          path.addPath(petal) }      shapeLayer.path = path shapeLayer.strokeColor = UIColor.red.cgColor shapeLayer.fillColor = UIColor.yellow.cgColor shapeLayer.fillRule = kCAFillRuleEvenOdd The following figure shows the resulting shape layer.

note: Shape rasterization may favor speed over accuracy. For example, pixels with multiple intersecting path segments may not give exact results.

## Topics

### Specifying the Shape Path

- [path](quartzcore/cashapelayer/path.md)

### Accessing Shape Style Properties

- [fillColor](quartzcore/cashapelayer/fillcolor.md)
- [fillRule](quartzcore/cashapelayer/fillrule.md)
- [lineCap](quartzcore/cashapelayer/linecap.md)
- [lineDashPattern](quartzcore/cashapelayer/linedashpattern.md)
- [lineDashPhase](quartzcore/cashapelayer/linedashphase.md)
- [lineJoin](quartzcore/cashapelayer/linejoin.md)
- [lineWidth](quartzcore/cashapelayer/linewidth.md)
- [miterLimit](quartzcore/cashapelayer/miterlimit.md)
- [strokeColor](quartzcore/cashapelayer/strokecolor.md)
- [strokeStart](quartzcore/cashapelayer/strokestart.md)
- [strokeEnd](quartzcore/cashapelayer/strokeend.md)

### Constants

- [Shape Fill Mode Values](quartzcore/shape-fill-mode-values.md)
- [Line Join Values](quartzcore/line-join-values.md)
- [Line Cap Values](quartzcore/line-cap-values.md)

## Relationships

### Inherits From

- [CALayer](quartzcore/calayer.md)

### Conforms To

- [CAMediaTiming](quartzcore/camediatiming.md)
- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCoding](foundation/nscoding.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [NSSecureCoding](foundation/nssecurecoding.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Text, Shapes, and Gradients

- [CATextLayer](quartzcore/catextlayer.md)
- [CAGradientLayer](quartzcore/cagradientlayer.md)
