# Map Custom Style

Last updated:

<!-- -->

October 18, 2026

<!-- -->

\| 2 minutes read

<br />

<br />

* UIKit
* SwiftUI

This example demonstrates how to apply a custom map style in a UIKit application. A custom map style can be created in our [Map Studio](https://developer.magiclane.com/docs/guides/map-studio/).

Check the full implementation on [GitHub](https://github.com/magiclane/magiclane-maps-sdk-examples-for-ios/tree/main/UIKit/3DScene/MapViewCustomStyle).

![Map view with custom style](/docs/ios/assets/images/example_ios_map_custom_style_uikit-89ba891acfa5be1f0b1f30745f934887.png)

**Map view with custom style**

### Map Display and applying the Style[​](#map-display-and-applying-the-style "Direct link to Map Display and applying the Style")

The following code outlines the main view, which displays the map and applies a custom style from the app's resources:

ViewController.swift[View on GitHub](https://github.com/magiclane/magiclane-maps-sdk-examples-for-ios/tree/main/UIKit/3DScene/MapViewCustomStyle/MapViewCustomStyle/ViewController.swift)

```swift
class ViewController: UIViewController {

    var mapViewController: MapViewController?

    override func viewDidLoad() {

        super.viewDidLoad()

        if let navigationController = self.navigationController {

            let appearance = navigationController.navigationBar.standardAppearance

            navigationController.navigationBar.scrollEdgeAppearance = appearance
        }

        self.createMapView()

        self.mapViewController!.hideCompass()

        self.setCustomStyle()
    }

    override func viewWillAppear(_ animated: Bool) {

        super.viewWillAppear(animated)

        self.mapViewController!.startRender()
    }

    // MARK: - Map View

    func createMapView() {

        self.mapViewController = MapViewController.init()
        self.mapViewController!.view.backgroundColor = UIColor.systemBackground

        self.addChild(self.mapViewController!)
        self.view.addSubview(self.mapViewController!.view)
        self.mapViewController!.didMove(toParent: self)

        self.mapViewController?.view.translatesAutoresizingMaskIntoConstraints = false
        NSLayoutConstraint.activate([
            self.mapViewController!.view.topAnchor.constraint(equalTo: self.view.topAnchor, constant: 0),
            self.mapViewController!.view.leadingAnchor.constraint(equalTo: self.view.leadingAnchor, constant: 0),
            self.mapViewController!.view.bottomAnchor.constraint(equalTo: self.view.bottomAnchor, constant: -0),
            self.mapViewController!.view.trailingAnchor.constraint(equalTo: self.view.trailingAnchor, constant: -0)
        ])
    }

    func setCustomStyle() {

        if let url = Bundle.main.url(forResource: "Basic1Oldtime", withExtension: "style") {

            if let data = NSData.init(contentsOf: url) as Data? {

                self.mapViewController!.applyStyle(withStyleBuffer: data, smoothTransition: false)
            }
        }
    }
}

```

This example demonstrates how to apply a custom map style in a SwiftUI application. A custom map style can be created in our [Map Studio](https://developer.magiclane.com/docs/guides/map-studio/).

Check the full implementation on [GitHub](https://github.com/magiclane/magiclane-maps-sdk-examples-for-ios/tree/main/SwiftUI/3DScene/MapCustomStyle).

![Map view with custom style](/docs/ios/assets/images/example_ios_map_custom_style_swiftui-5d009d96b5187a2da88bba45ffbc7e2d.png)

**Map view with custom style**

### Map Display and applying the Style[​](#map-display-and-applying-the-style-1 "Direct link to Map Display and applying the Style")

The following code outlines the main view, which displays the map and applies a custom style from the app's resources:

ContentView\.swift[View on GitHub](https://github.com/magiclane/magiclane-maps-sdk-examples-for-ios/tree/main/SwiftUI/3DScene/MapCustomStyle/MapCustomStyle/ContentView.swift)

```swift
struct ContentView: View {

    var body: some View {
        MapReader { proxy in
            MapBase()
                .onAppear {
                    applyCustomMapStyle(proxy)
                }
                .ignoresSafeArea()
        }
    }
    
    func applyCustomMapStyle(_ proxy: MapProxy) {
        guard let url = Bundle.main.url(forResource: "CustomMapStyle", withExtension: "style") else { return }
        if let data = NSData.init(contentsOf: url) as Data? {
            proxy.setMapStyle(data: data, smoothTransition: true)
        }
    }
}

```
