---
title: "MTBackgroundLayer | Mobile sdk | Mobile sdk ios | Ios"
description: "The background style layer covers the entire map. Use a background style layer to configure a color or pattern to show below all other map content. If the background layer is transparent or omitted from the style, any part of the map view that does not show another style layer is transparent."
---

> For AI agents: a documentation index is available at [/llms.txt](https://docs.maptiler.com/llms.txt). Markdown versions of all pages are available by appending .md to any URL.

# MTBackgroundLayer

```
public class MTBackgroundLayer : MTLayer, @unchecked Sendable, Codable
```

The background style layer covers the entire map. Use a background style layer to configure a color or pattern to show below all other map content. If the background layer is transparent or omitted from the style, any part of the map view that does not show another style layer is transparent.

[](#/Core%20properties)

### Core properties

-   `[identifier](#/s:11MapTilerSDK17MTBackgroundLayerC10identifierSSvp)`
    
    Unique layer identifier.
    
    #### Declaration
    
    Swift
    
    ```
    public var identifier: String
    ```
    
-   `[type](#/s:11MapTilerSDK17MTBackgroundLayerC4typeAA11MTLayerTypeOvp)`
    
    Type of the layer.
    
    #### Declaration
    
    Swift
    
    ```
    public private(set) var type: MTLayerType { get }
    ```
    
-   `[sourceIdentifier](#/s:11MapTilerSDK17MTBackgroundLayerC16sourceIdentifierSSvp)`
    
    Background layers have no source. This placeholder satisfies the `[MTLayer](https://docs.maptiler.com/mobile-sdk/ios/api/Protocols/MTLayer/)` protocol. It is ignored during encoding/decoding and by the style bridge.
    
    #### Declaration
    
    Swift
    
    ```
    public var sourceIdentifier: String
    ```
    
-   `[maxZoom](#/s:11MapTilerSDK17MTBackgroundLayerC7maxZoomSdSgvp)`
    
    The maximum zoom level for the layer. Optional number between 0 and 24. At zoom levels equal to or greater than the maxzoom, the layer will be hidden.
    
    #### Declaration
    
    Swift
    
    ```
    public var maxZoom: Double?
    ```
    
-   `[minZoom](#/s:11MapTilerSDK17MTBackgroundLayerC7minZoomSdSgvp)`
    
    The minimum zoom level for the layer. Optional number between 0 and 24. At zoom levels less than the minzoom, the layer will be hidden.
    
    #### Declaration
    
    Swift
    
    ```
    public var minZoom: Double?
    ```
    
-   `[sourceLayer](#/s:11MapTilerSDK17MTBackgroundLayerC06sourceE0SSSgvp)`
    
    Background layers have no source layer; present only to satisfy `[MTLayer](https://docs.maptiler.com/mobile-sdk/ios/api/Protocols/MTLayer/)` protocol.
    
    #### Declaration
    
    Swift
    
    ```
    public var sourceLayer: String?
    ```
    

[](#/Paint%20properties)

### Paint properties

-   `[color](#/s:11MapTilerSDK17MTBackgroundLayerC5colorAA12MTStyleValueOSgvp)`
    
    The color with which the background will be drawn. Can be a constant color or an expression. Defaults to black.
    
    #### Declaration
    
    Swift
    
    ```
    public var color: MTStyleValue?
    ```
    
-   `[opacity](#/s:11MapTilerSDK17MTBackgroundLayerC7opacitySdSgvp)`
    
    The opacity at which the background will be drawn. Optional number between 0 and 1 inclusive. Defaults to 1.
    
    #### Declaration
    
    Swift
    
    ```
    public var opacity: Double?
    ```
    
-   `[pattern](#/s:11MapTilerSDK17MTBackgroundLayerC7patternSSSgvp)`
    
    Name of image in sprite to use for drawing an image background. For seamless patterns, image width and height must be a factor of two.
    
    #### Declaration
    
    Swift
    
    ```
    public var pattern: String?
    ```
    

[](#/Layout%20properties)

### Layout properties

-   `[visibility](#/s:11MapTilerSDK17MTBackgroundLayerC10visibilityAA17MTLayerVisibilityOSgvp)`
    
    Whether this layer is displayed. Defaults to “visible”.
    
    #### Declaration
    
    Swift
    
    ```
    public var visibility: MTLayerVisibility?
    ```
    

[](#/Initializers)

### Initializers

-   `[init(identifier:)](#/s:11MapTilerSDK17MTBackgroundLayerC10identifierACSS_tcfc)`
    
    Initializes the background layer with an identifier.
    
    #### Declaration
    
    Swift
    
    ```
    public init(identifier: String)
    ```
    
-   `[init(identifier:maxZoom:minZoom:color:opacity:pattern:visibility:)](#/s:11MapTilerSDK17MTBackgroundLayerC10identifier7maxZoom03minH05color7opacity7pattern10visibilityACSS_SdSgAkA12MTStyleValueOSgAKSSSgAA17MTLayerVisibilityOSgtcfc)`
    
    Initializes the background layer with all options.
    
    #### Declaration
    
    Swift
    
    ```
    public init(
        identifier: String,
        maxZoom: Double? = nil,
        minZoom: Double? = nil,
        color: MTStyleValue? = .color(.black),
        opacity: Double? = 1.0,
        pattern: String? = nil,
        visibility: MTLayerVisibility? = .visible
    )
    ```
    

[](#/Codable)

### Codable

-   `[init(from:)](#/s:11MapTilerSDK17MTBackgroundLayerC4fromACs7Decoder_p_tKcfc)`
    
    Initializes layer from the decoder.
    
    #### Declaration
    
    Swift
    
    ```
    public required init(from decoder: any Decoder) throws
    ```
    
-   `[encode(to:)](#/s:SE6encode2toys7Encoder_p_tKF)`
    
    #### Declaration
    
    Swift
    
    ```
    public func encode(to encoder: Encoder) throws
    ```
    
-   `[addToMap(_:)](#/s:11MapTilerSDK17MTBackgroundLayerC05addToA0yyAA9MTMapViewCF)`
    
    Adds layer to map DSL style.
    
    Prefer `[MTStyle.addLayer(_:)](https://docs.maptiler.com/mobile-sdk/ios/api/Classes/MTStyle/#/s:11MapTilerSDK7MTStyleC8addLayeryyAA7MTLayer_pYaKF)` on MTMapView instead.
    
    #### Declaration
    
    Swift
    
    ```
    public func addToMap(_ mapView: MTMapView)
    ```
    

[](#/Modifiers%20%28for%20DSL%20chaining%29.%20Not%20for%20external%20use.)

### Modifiers (for DSL chaining). Not for external use.

-   `[maxZoom(_:)](#/s:11MapTilerSDK17MTBackgroundLayerC7maxZoomyACXDSdF)`
    
    Undocumented
    
    #### Declaration
    
    Swift
    
    ```
    @discardableResult
    public func maxZoom(_ value: Double) -> Self
    ```
    
-   `[minZoom(_:)](#/s:11MapTilerSDK17MTBackgroundLayerC7minZoomyACXDSdF)`
    
    Undocumented
    
    #### Declaration
    
    Swift
    
    ```
    @discardableResult
    public func minZoom(_ value: Double) -> Self
    ```
    
-   `[color(_:)](#/s:11MapTilerSDK17MTBackgroundLayerC5coloryACXDSo7UIColorCF)`
    
    Sets a constant background color value.
    
    #### Declaration
    
    Swift
    
    ```
    @discardableResult
    public func color(_ value: UIColor) -> Self
    ```
    
-   `[paintColorExpression(_:)](#/s:11MapTilerSDK17MTBackgroundLayerC20paintColorExpressionyACXDAA15MTPropertyValueOF)`
    
    Sets a background color expression (e.g., interpolate by zoom).
    
    #### Declaration
    
    Swift
    
    ```
    @discardableResult
    public func paintColorExpression(_ expr: MTPropertyValue) -> Self
    ```
    
-   `[opacity(_:)](#/s:11MapTilerSDK17MTBackgroundLayerC7opacityyACXDSdF)`
    
    Sets the background opacity (0–1).
    
    #### Declaration
    
    Swift
    
    ```
    @discardableResult
    public func opacity(_ value: Double) -> Self
    ```
    
-   `[pattern(_:)](#/s:11MapTilerSDK17MTBackgroundLayerC7patternyACXDSSF)`
    
    Sets the background sprite pattern name.
    
    #### Declaration
    
    Swift
    
    ```
    @discardableResult
    public func pattern(_ value: String) -> Self
    ```
    
-   `[visibility(_:)](#/s:11MapTilerSDK17MTBackgroundLayerC10visibilityyACXDAA17MTLayerVisibilityOF)`
    
    Sets the background visibility.
    
    #### Declaration
    
    Swift
    
    ```
    @discardableResult
    public func visibility(_ value: MTLayerVisibility) -> Self
    ```
