From f5a9b0e07336e8155c45e79c081b7db679f47784 Mon Sep 17 00:00:00 2001 From: Fabian Guerra Date: Tue, 20 Aug 2019 10:21:17 -0700 Subject: [ios] Padding test. --- .../background.imageset/Contents.json | 21 ++++++++++++++++++ .../background.imageset/backgroung.sdf.png | Bin 0 -> 240 bytes platform/ios/app/Info.plist | 2 ++ platform/ios/app/MBXViewController.m | 24 ++++++++++++++++++--- platform/ios/ios.xcodeproj/project.pbxproj | 4 ++-- 5 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 platform/ios/app/Assets.xcassets/background.imageset/Contents.json create mode 100644 platform/ios/app/Assets.xcassets/background.imageset/backgroung.sdf.png diff --git a/platform/ios/app/Assets.xcassets/background.imageset/Contents.json b/platform/ios/app/Assets.xcassets/background.imageset/Contents.json new file mode 100644 index 0000000000..7800a00a58 --- /dev/null +++ b/platform/ios/app/Assets.xcassets/background.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "backgroung.sdf.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/platform/ios/app/Assets.xcassets/background.imageset/backgroung.sdf.png b/platform/ios/app/Assets.xcassets/background.imageset/backgroung.sdf.png new file mode 100644 index 0000000000..777c75beb4 Binary files /dev/null and b/platform/ios/app/Assets.xcassets/background.imageset/backgroung.sdf.png differ diff --git a/platform/ios/app/Info.plist b/platform/ios/app/Info.plist index c302f306a6..a299172fa8 100644 --- a/platform/ios/app/Info.plist +++ b/platform/ios/app/Info.plist @@ -53,6 +53,8 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight + MGLMapboxAccessToken + insert here your token UIApplicationShortcutItems diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m index 2fb95e1b17..2bd9f94d7b 100644 --- a/platform/ios/app/MBXViewController.m +++ b/platform/ios/app/MBXViewController.m @@ -1111,8 +1111,26 @@ CLLocationCoordinate2D randomWorldCoordinate() { - (void)styleSymbolLayer { - MGLSymbolStyleLayer *stateLayer = (MGLSymbolStyleLayer *)[self.mapView.style layerWithIdentifier:@"state-label-lg"]; - stateLayer.textColor = [NSExpression expressionForConstantValue:[UIColor redColor]]; + UIImage *background = [UIImage imageNamed:@"background"]; + UIImage *backgroundSDF = [background imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; + [self.mapView.style setImage:backgroundSDF forName:@"background"]; + + MGLSymbolStyleLayer *symbolStyleLayer = (MGLSymbolStyleLayer *)[self.mapView.style layerWithIdentifier:@"road-intersections"]; + symbolStyleLayer.iconImageName = [NSExpression expressionForConstantValue:@"background"]; + symbolStyleLayer.iconTextFit = [NSExpression expressionForConstantValue:[NSValue valueWithMGLIconTextFit:MGLIconTextFitBoth]]; + symbolStyleLayer.iconScale = [NSExpression expressionForConstantValue:@1.0]; + UIEdgeInsets padding = UIEdgeInsetsMake(5.0, 5.0, 5.0, 5.0); // padding is evenly distributed + symbolStyleLayer.iconTextFitPadding = [NSExpression expressionForConstantValue:[NSValue valueWithUIEdgeInsets:padding]]; + + symbolStyleLayer.iconColor = [NSExpression expressionForConstantValue:UIColor.whiteColor]; + UIColor *haloColor = [UIColor colorWithRed:(51.0/255) green:(117.0/255) blue:(197.0/255) alpha:1.0]; + symbolStyleLayer.iconHaloColor = [NSExpression expressionForConstantValue:haloColor]; + symbolStyleLayer.iconHaloWidth = [NSExpression expressionForConstantValue:@4.0]; + + symbolStyleLayer.textHaloColor = [NSExpression expressionForConstantValue:UIColor.whiteColor]; + symbolStyleLayer.textHaloWidth = [NSExpression expressionForConstantValue:@0.5]; + symbolStyleLayer.textHaloBlur = [NSExpression expressionForConstantValue:@0.5]; + symbolStyleLayer.textColor = [NSExpression expressionForConstantValue:haloColor]; } - (void)styleBuildingLayer @@ -1996,7 +2014,7 @@ CLLocationCoordinate2D randomWorldCoordinate() { self.styleIndex = (self.styleIndex + 1) % styleNames.count; - self.mapView.styleURL = styleURLs[self.styleIndex]; + self.mapView.styleURL = [NSURL URLWithString:@"insert here your url"]; UIButton *titleButton = (UIButton *)self.navigationItem.titleView; [titleButton setTitle:styleNames[self.styleIndex] forState:UIControlStateNormal]; diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj index 49043bdeee..9a2f9d8602 100644 --- a/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/ios.xcodeproj/project.pbxproj @@ -1197,8 +1197,8 @@ CA55CD3E202C16AA00CE7095 /* MGLCameraChangeReason.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLCameraChangeReason.h; sourceTree = ""; }; CA5E5042209BDC5F001A8A81 /* MGLTestUtility.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = MGLTestUtility.h; path = ../../darwin/test/MGLTestUtility.h; sourceTree = ""; }; CA65C4F721E9BB080068B0D4 /* MGLCluster.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLCluster.h; sourceTree = ""; }; - CA86FF0D22D8D5A0009EB14A /* MGLNetworkConfigurationTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLNetworkConfigurationTests.m; sourceTree = ""; }; CA6914B420E67F50002DB0EE /* MGLAnnotationViewIntegrationTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLAnnotationViewIntegrationTests.mm; path = "Annotation Tests/MGLAnnotationViewIntegrationTests.mm"; sourceTree = ""; }; + CA86FF0D22D8D5A0009EB14A /* MGLNetworkConfigurationTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLNetworkConfigurationTests.m; sourceTree = ""; }; CA88DC2F21C85D900059ED5A /* MGLStyleURLIntegrationTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLStyleURLIntegrationTest.m; sourceTree = ""; }; CA8FBC0821A47BB100D1203C /* MGLRendererConfigurationTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLRendererConfigurationTests.mm; path = ../../darwin/test/MGLRendererConfigurationTests.mm; sourceTree = ""; }; CAD9D0A922A86D6F001B25EE /* MGLResourceTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLResourceTests.mm; path = ../../darwin/test/MGLResourceTests.mm; sourceTree = ""; }; @@ -3157,7 +3157,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "$SRCROOT/app/insert_access_token.sh\n"; + shellScript = "#$SRCROOT/app/insert_access_token.sh\n"; }; 07796BA2227908CB0059CAF1 /* Insert Mapbox Access Token */ = { isa = PBXShellScriptBuildPhase; -- cgit v1.2.1