---
title: "hitTest(_:)"
framework: quartzcore
role: symbol
role_heading: Instance Method
path: "quartzcore/calayer/hittest(_:)"
---

# hitTest(_:)

Returns the farthest descendant of the receiver in the layer hierarchy (including itself) that contains the specified point.

## Declaration

```swift
func hitTest(_ p: CGPoint) -> CALayer?
```

## Parameters

- `p`: A point in the coordinate system of the receiver’s superlayer.

## Return Value

Return Value The layer that contains thePoint or nil if the point lies outside the receiver’s bounds rectangle.

## See Also

### Hit testing

- [contains(_:)](quartzcore/calayer/contains(_:).md)
