---
title: "insertSublayer(_:above:)"
framework: quartzcore
role: symbol
role_heading: Instance Method
path: "quartzcore/calayer/insertsublayer(_:above:)"
---

# insertSublayer(_:above:)

Inserts the specified sublayer above a different sublayer that already belongs to the receiver.

## Declaration

```swift
func insertSublayer(_ layer: CALayer, above sibling: CALayer?)
```

## Parameters

- `layer`: The sublayer to be inserted into the current layer.
- `sibling`: An existing sublayer in the current layer. The layer in aLayer is inserted after this layer in the doc://com.apple.quartzcore/documentation/QuartzCore/CALayer/sublayers array, and thus appears in front of it visually.

## Discussion

Discussion If sublayer is not in the receiver’s sublayers array, this method raises an exception.

## See Also

### Managing the layer hierarchy

- [sublayers](quartzcore/calayer/sublayers.md)
- [superlayer](quartzcore/calayer/superlayer.md)
- [addSublayer(_:)](quartzcore/calayer/addsublayer(_:).md)
- [removeFromSuperlayer()](quartzcore/calayer/removefromsuperlayer().md)
- [insertSublayer(_:at:)](quartzcore/calayer/insertsublayer(_:at:).md)
- [insertSublayer(_:below:)](quartzcore/calayer/insertsublayer(_:below:).md)
- [replaceSublayer(_:with:)](quartzcore/calayer/replacesublayer(_:with:).md)
