<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLTexture/newTextureViewWithPixelFormat:textureType:levels:slices:",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(pl)MTLTexture(im)newTextureViewWithPixelFormat:textureType:levels:slices:"
  },
  "title" : "newTextureViewWithPixelFormat:textureType:levels:slices:"
}
-->

# newTextureViewWithPixelFormat:textureType:levels:slices:

Creates a new view of the texture, reinterpreting a subset of its data using a different type and pixel format.

```
- (id<MTLTexture>) newTextureViewWithPixelFormat:(MTLPixelFormat) pixelFormat textureType:(MTLTextureType) textureType levels:(NSRange) levelRange slices:(NSRange) sliceRange;
```

## Parameters

`pixelFormat`

A new pixel format, which needs to be compatible with the original pixel format.

`textureType`

A new texture type, which can be cast according to the original texture type as listed in the table below.

`levelRange`

A new base level range that restricts which mipmap levels are visible in the new texture.

`sliceRange`

A new base slice range that restricts which array slices are visible in the new texture.

## Return Value

A new texture object that shares the same storage allocation of the calling texture object.

## Discussion

The texture type can be cast between the targets listed in the following table.

|Original texture type                                                                                                                                                                                                         |New texture type                                                                                                                                                                                                                                                                                   |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|``doc://com.apple.metal/documentation/Metal/MTLTextureType/type1D``                                                                                                                                                           |``doc://com.apple.metal/documentation/Metal/MTLTextureType/type1D``                                                                                                                                                                                                                                |
|``doc://com.apple.metal/documentation/Metal/MTLTextureType/type2D``                                                                                                                                                           |``doc://com.apple.metal/documentation/Metal/MTLTextureType/type2D`` or ``doc://com.apple.metal/documentation/Metal/MTLTextureType/type2DArray``                                                                                                                                                    |
|``doc://com.apple.metal/documentation/Metal/MTLTextureType/type2DArray``, ``doc://com.apple.metal/documentation/Metal/MTLTextureType/typeCube``, or ``doc://com.apple.metal/documentation/Metal/MTLTextureType/typeCubeArray``|``doc://com.apple.metal/documentation/Metal/MTLTextureType/type2D``, ``doc://com.apple.metal/documentation/Metal/MTLTextureType/type2DArray``, ``doc://com.apple.metal/documentation/Metal/MTLTextureType/typeCube``, or ``doc://com.apple.metal/documentation/Metal/MTLTextureType/typeCubeArray``|
|``doc://com.apple.metal/documentation/Metal/MTLTextureType/type3D``                                                                                                                                                           |``doc://com.apple.metal/documentation/Metal/MTLTextureType/type3D``                                                                                                                                                                                                                                |

The `length` value of the `sliceRange` parameter needs to be `6` if the new texture type value is [`MTLTextureType.typeCube`](/documentation/Metal/MTLTextureType/typeCube), or a multiple of `6` if the new texture type value is [`MTLTextureType.typeCubeArray`](/documentation/Metal/MTLTextureType/typeCubeArray).

For more information on pixel format restrictions, see [`makeTextureView(pixelFormat:)`](/documentation/Metal/MTLTexture/makeTextureView(pixelFormat:))

## See Also

[`parentRelativeLevel`](/documentation/Metal/MTLTexture/parentRelativeLevel)

The base level of the parent texture used to create this texture.

[`parent`](/documentation/Metal/MTLTexture/parent)

The parent texture used to create this texture, if any.

[`parentRelativeSlice`](/documentation/Metal/MTLTexture/parentRelativeSlice)

The base slice of the parent texture used to create this texture.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)