diff options
-rw-r--r-- | platform/ios/src/MGLScaleBar.mm | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/platform/ios/src/MGLScaleBar.mm b/platform/ios/src/MGLScaleBar.mm index 9590a99438..993852d8b9 100644 --- a/platform/ios/src/MGLScaleBar.mm +++ b/platform/ios/src/MGLScaleBar.mm @@ -84,7 +84,7 @@ static const MGLRow MGLImperialTable[] ={ @property (nonatomic) UIColor *secondaryColor; @property (nonatomic) CALayer *borderLayer; @property (nonatomic, assign) CGFloat borderWidth; -@property (nonatomic) NSCache* labelImageCache; +@property (nonatomic) NSMutableDictionary* labelImageCache; @property (nonatomic) MGLScaleBarLabel* prototypeLabel; @property (nonatomic) CGFloat lastLabelWidth; @@ -159,7 +159,7 @@ static const CGFloat MGLFeetPerMeter = 3.28084; _formatter = [[MGLDistanceFormatter alloc] init]; // Image labels are now images - _labelImageCache = [[NSCache alloc] init]; + _labelImageCache = [[NSMutableDictionary alloc] init]; _prototypeLabel = [[MGLScaleBarLabel alloc] init]; _prototypeLabel.font = [UIFont systemFontOfSize:8 weight:UIFontWeightMedium]; _prototypeLabel.clipsToBounds = NO; @@ -180,6 +180,17 @@ static const CGFloat MGLFeetPerMeter = 3.28084; // Zero is a special case (no formatting) [self addZeroLabel]; + + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(resetLabelImageCache) name:NSCurrentLocaleDidChangeNotification object:nil]; +} + +- (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; +} + +- (void)resetLabelImageCache { + self.labelImageCache = [[NSMutableDictionary alloc] init]; + [self addZeroLabel]; } #pragma mark - Dimensions |