newTexture(name:scaleFactor:bundle:options:completionHandler:)
Asynchronously loads image data and creates a Metal texture from the named texture asset in an asset catalog.
Declaration
func newTexture(name: String, scaleFactor: CGFloat, bundle: Bundle?, options: [MTKTextureLoader.Option : Any]? = nil, completionHandler: @escaping @Sendable ((any MTLTexture)?, (any Error)?) -> Void)func newTexture(name: String, scaleFactor: CGFloat, bundle: Bundle?, options: [MTKTextureLoader.Option : Any]? = nil) async throws -> any MTLTextureParameters
- name:
The name of a texture in an asset catalog.
- scaleFactor:
The scale factor of texture to request.
In iOS and tvOS, pass the Contentsscale value of the view where you plan to display texture content.
In macOS, pass the Backingscalefactor value of the window where you plan to display texture content.
- bundle:
The resource bundle containing the asset catalog to load the texture from.
- options:
A dictionary describing any additional texture loading steps. See
Texture Loading Options.When using this method, the texture loader ignores the Generatemipmaps, Srgb, Cubelayout, and Origin options.
- completionHandler:
A block called when the texture has been loaded and fully initialized.
Discussion
See Also
Loading Textures from Asset Catalogs
newTexture(name:scaleFactor:bundle:options:)newTextures(names:scaleFactor:bundle:options:completionHandler:)newTexture(name:scaleFactor:displayGamut:bundle:options:)newTexture(name:scaleFactor:displayGamut:bundle:options:completionHandler:)newTextures(names:scaleFactor:displayGamut:bundle:options:completionHandler:)