Custom style

Use a style created in Mapbox Studio with the Mapbox iOS SDK.

For raster maps created with legacy Mapbox tools, see the custom raster styles example.
import Mapbox

class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // Fill in the next line with your style URL from Mapbox Studio.
        let styleURL = NSURL(string: <#mapbox://styles/userName/styleHash#>)
        let mapView = MGLMapView(frame: view.bounds,
                                 styleURL: styleURL as URL?)
        mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
        
        // Set the map’s center coordinate and zoom level.
        mapView.setCenter(CLLocationCoordinate2D(latitude: 45.52954,
            longitude: -122.72317),
                          zoomLevel: 14, animated: false)
        view.addSubview(mapView)
    }
}
#import "ViewController.h"
@import Mapbox;

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    // Fill in the next line with your style URL from Mapbox Studio.
    NSURL *styleURL = [NSURL URLWithString:<#mapbox://styles/userName/styleHash#>];
    MGLMapView *mapView = [[MGLMapView alloc] initWithFrame:self.view.bounds
                                                   styleURL:styleURL];

    mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

    // Set the map’s center coordinate and zoom level.
    [mapView setCenterCoordinate:CLLocationCoordinate2DMake(45.52954, -122.72317)
                       zoomLevel:14
                        animated:NO];

    [self.view addSubview:mapView];
}

@end