diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2016-07-26 22:45:29 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-26 22:45:29 -0700 |
commit | 850b2e29889091684b088ad64741aa469a8db628 (patch) | |
tree | bafb511b7032ba700445bae3c11eb57e5e801695 /platform | |
parent | 59f1b2b210318e204ebb2b7423ae5c0e8790dd3a (diff) | |
download | qtlocation-mapboxgl-850b2e29889091684b088ad64741aa469a8db628.tar.gz |
[ios] Fixed crash drawing compass on iOS 8.1 (#5791)
Fixes #5780.
Diffstat (limited to 'platform')
-rw-r--r-- | platform/ios/CHANGELOG.md | 4 | ||||
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 13 |
2 files changed, 15 insertions, 2 deletions
diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index 049d165c2c..e55624f8bb 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -2,6 +2,10 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONTRIBUTING.md](../../CONTRIBUTING.md) to get started. +## 3.3.2 + +* Fixed a crash that occurred when initializing an MGLMapView on iOS 8.1 or below. ([#5791](https://github.com/mapbox/mapbox-gl-native/pull/5791)) + ## 3.3.1 * Fixed a crash that occurred when a sprite URL lacks a file extension. See [this comment](https://github.com/mapbox/mapbox-gl-native/issues/5722#issuecomment-233701251) to determine who may be affected by this bug. ([#5723](https://github.com/mapbox/mapbox-gl-native/pull/5723)) diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 4d692fa718..b36efe3bd7 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -586,9 +586,18 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration) UIGraphicsBeginImageContextWithOptions(scaleImage.size, NO, [UIScreen mainScreen].scale); [scaleImage drawInRect:{ CGPointZero, scaleImage.size }]; - CGFloat weight = &UIFontWeightUltraLight ? UIFontWeightUltraLight : -0.8; + CGFloat northSize = 9; + UIFont *northFont; + if ([UIFont respondsToSelector:@selector(systemFontOfSize:weight:)]) + { + northFont = [UIFont systemFontOfSize:northSize weight:UIFontWeightUltraLight]; + } + else + { + northFont = [UIFont systemFontOfSize:northSize]; + } NSAttributedString *north = [[NSAttributedString alloc] initWithString:NSLocalizedStringWithDefaultValue(@"COMPASS_NORTH", nil, nil, @"N", @"Compass abbreviation for north") attributes:@{ - NSFontAttributeName: [UIFont systemFontOfSize:9 weight:weight], + NSFontAttributeName: northFont, NSForegroundColorAttributeName: [UIColor whiteColor], }]; CGRect stringRect = CGRectMake((scaleImage.size.width - north.size.width) / 2, |