---
title: "MTColorValue | Mobile sdk | Mobile sdk ios | Ios"
description: "Encodes a color to a hex string when converted to JSON. Accepts either a hex color string (e.g. “#RRGGBB”) or a UIColor."
---

> 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.

# MTColorValue

```
public struct MTColorValue : Codable, Sendable
```

Encodes a color to a hex string when converted to JSON. Accepts either a hex color string (e.g. “#RRGGBB”) or a UIColor.

-   `[raw](#/s:11MapTilerSDK12MTColorValueV3rawSSvp)`
    
    Undocumented
    
    #### Declaration
    
    Swift
    
    ```
    public let raw: String
    ```
    
-   `[init(_:)](#/s:11MapTilerSDK12MTColorValueVyACSScfc)`
    
    Undocumented
    
    #### Declaration
    
    Swift
    
    ```
    public init(_ hexColor: String)
    ```
    
-   `[init(_:)](#/s:11MapTilerSDK12MTColorValueVyACSo7UIColorCcfc)`
    
    Undocumented
    
    #### Declaration
    
    Swift
    
    ```
    public init(_ color: UIColor)
    ```
    
-   `[init(from:)](#/s:Se4fromxs7Decoder_p_tKcfc)`
    
    #### Declaration
    
    Swift
    
    ```
    public init(from decoder: any Decoder) throws
    ```
    
-   `[encode(to:)](#/s:SE6encode2toys7Encoder_p_tKF)`
    
    #### Declaration
    
    Swift
    
    ```
    public func encode(to encoder: any Encoder) throws
    ```
