diff options
author | Jason Wray <friedbunny@users.noreply.github.com> | 2019-07-11 16:06:54 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-11 16:06:54 -0700 |
commit | 5b488225fb720ef607c13a33ff6509d92bb7de95 (patch) | |
tree | 6b3f61c1d27110fb3f4bd2ea51e4be5697443c22 /platform/ios/src/UIImage+MGLAdditions.mm | |
parent | de71ff5102987d66ce7578216b32ae13ecf9622f (diff) | |
download | qtlocation-mapboxgl-5b488225fb720ef607c13a33ff6509d92bb7de95.tar.gz |
[ios] Add MGLCompassButton and MGLOrnamentVisibility
Diffstat (limited to 'platform/ios/src/UIImage+MGLAdditions.mm')
-rw-r--r-- | platform/ios/src/UIImage+MGLAdditions.mm | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/platform/ios/src/UIImage+MGLAdditions.mm b/platform/ios/src/UIImage+MGLAdditions.mm index 884f92e003..9d05abd6ca 100644 --- a/platform/ios/src/UIImage+MGLAdditions.mm +++ b/platform/ios/src/UIImage+MGLAdditions.mm @@ -1,7 +1,10 @@ #import "UIImage+MGLAdditions.h" +#import "NSBundle+MGLAdditions.h" #include <mbgl/util/image+MGLAdditions.hpp> +const MGLExceptionName MGLResourceNotFoundException = @"MGLResourceNotFoundException"; + @implementation UIImage (MGLAdditions) - (nullable instancetype)initWithMGLStyleImage:(const mbgl::style::Image *)styleImage @@ -42,7 +45,20 @@ float(self.scale), isTemplate); } --(mbgl::PremultipliedImage)mgl_premultipliedImage { +- (mbgl::PremultipliedImage)mgl_premultipliedImage { return MGLPremultipliedImageFromCGImage(self.CGImage); } + ++ (UIImage *)mgl_resourceImageNamed:(NSString *)imageName { + UIImage *image = [UIImage imageNamed:imageName + inBundle:[NSBundle mgl_frameworkBundle] + compatibleWithTraitCollection:nil]; + + if (!image) { + [NSException raise:MGLResourceNotFoundException format:@"The resource named “%@” could not be found in the Mapbox framework bundle.", imageName]; + } + + return image; +} + @end |