Initializes a texture that creates a vertical gradient between two colors.


init(colorGradientFrom color1: CGColor, to color2: CGColor, name: String?, textureDimensions: vector_int2)



The color at the top of the gradient.


The color at the bottom of the gradient.


The name property for the new texture object.


The texel dimensions (width and height) of the texture image.

Return Value

A new color swatch texture object.


Model I/O interpolates between the color1 and color2 colors by hue, saturation, and lightness to create a color gradient when generating texture data.

This initializer does not generate texel data; the MDLColorSwatchTexture class automatically generates data and caches it for reuse when you use one of the MDLTexture methods listed in Accessing Texture Data.

See Also

Creating a Color Swatch Texture

init(colorTemperatureGradientFrom: Float, toColorTemperature: Float, name: String?, textureDimensions: vector_int2)

Initializes a texture that creates a vertical gradient between two color temperatures.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software