Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Transparent GLKView #3096

Merged
merged 1 commit into from
Jan 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 14 additions & 0 deletions platform/ios/src/MGLMapView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ @implementation MGLMapView
MBGLView *_mbglView;
std::shared_ptr<mbgl::SQLiteCache> _mbglFileCache;
mbgl::DefaultFileSource *_mbglFileSource;

BOOL _opaque;

NS_MUTABLE_ARRAY_OF(NSURL *) *_bundledStyleURLs;

Expand Down Expand Up @@ -257,6 +259,7 @@ - (void)setStyleURL:(nullable NSURL *)styleURL
- (void)commonInit
{
_isTargetingInterfaceBuilder = NSProcessInfo.processInfo.mgl_isInterfaceBuilderDesignablesAgent;
_opaque = YES;

BOOL background = [UIApplication sharedApplication].applicationState == UIApplicationStateBackground;
if (!background)
Expand Down Expand Up @@ -450,6 +453,7 @@ - (void)createGLView
_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];
Expand Down Expand Up @@ -714,6 +718,16 @@ - (void)updateConstraints
[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
{
Expand Down