diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2015-11-20 16:04:35 -0800 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2016-01-05 10:01:31 -0800 |
commit | 5f58c015e4fe5cb93d04f959ffd1dc65ea760375 (patch) | |
tree | 287828a30f19cba9f3704292bc9e81418f34b1c7 | |
parent | f8f735b5745051e94cf4f527a5b33b09825bc86d (diff) | |
download | qtlocation-mapboxgl-5f58c015e4fe5cb93d04f959ffd1dc65ea760375.tar.gz |
[iOS] Transparent GLKView
Tie layer opacity to view opacity.
Fixes #3038.
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 14 |
2 files changed, 15 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 935fa1c211..ed2070a9df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ Known issues: - The user dot’s callout view is now centered above the user dot. It was previously offset slightly to the left. ([#3261](https://github.com/mapbox/mapbox-gl-native/pull/3261)) - Fixed an issue with small map views not properly fitting annotations within bounds. (#[3407](https://github.com/mapbox/mapbox-gl-native/pull/3407)) - The map will now snap to north. ([#3403](https://github.com/mapbox/mapbox-gl-native/pull/3403)) +- The map view’s background can now be transparent or translucent, as long as the style’s background layer is transparent or translucent and `MGLMapView.opaque` is set to `NO`. ([#3096](https://github.com/mapbox/mapbox-gl-native/pull/3096)) ## iOS 3.0.1 diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 5eee1d52ff..0f969e494c 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -157,6 +157,8 @@ public: MBGLView *_mbglView; std::shared_ptr<mbgl::SQLiteCache> _mbglFileCache; mbgl::DefaultFileSource *_mbglFileSource; + + BOOL _opaque; NS_MUTABLE_ARRAY_OF(NSURL *) *_bundledStyleURLs; @@ -257,6 +259,7 @@ std::chrono::steady_clock::duration MGLDurationInSeconds(float duration) - (void)commonInit { _isTargetingInterfaceBuilder = NSProcessInfo.processInfo.mgl_isInterfaceBuilderDesignablesAgent; + _opaque = YES; BOOL background = [UIApplication sharedApplication].applicationState == UIApplicationStateBackground; if (!background) @@ -450,6 +453,7 @@ std::chrono::steady_clock::duration MGLDurationInSeconds(float duration) _glView.drawableStencilFormat = GLKViewDrawableStencilFormat8; _glView.drawableDepthFormat = GLKViewDrawableDepthFormat16; _glView.contentScaleFactor = [UIScreen instancesRespondToSelector:@selector(nativeScale)] ? [[UIScreen mainScreen] nativeScale] : [[UIScreen mainScreen] scale]; + _glView.layer.opaque = _opaque; _glView.delegate = self; [_glView bindDrawable]; [self insertSubview:_glView atIndex:0]; @@ -714,6 +718,16 @@ std::chrono::steady_clock::duration MGLDurationInSeconds(float duration) [super updateConstraints]; } +- (BOOL)isOpaque +{ + return _opaque; +} + +- (void)setOpaque:(BOOL)opaque +{ + _glView.layer.opaque = _opaque = opaque; +} + // This is the delegate of the GLKView object's display call. - (void)glkView:(__unused GLKView *)view drawInRect:(__unused CGRect)rect { |