Authored by Justin R. Miller

basic iOS 7 tint response for user location tracking (dot/halo/accuracy)

@@ -98,6 +98,8 @@ @@ -98,6 +98,8 @@
98 @property (nonatomic, retain) CLHeading *heading; 98 @property (nonatomic, retain) CLHeading *heading;
99 @property (nonatomic, assign) BOOL hasCustomLayer; 99 @property (nonatomic, assign) BOOL hasCustomLayer;
100 100
  101 +- (void)updateTintColor;
  102 +
101 @end 103 @end
102 104
103 #pragma mark - 105 #pragma mark -
@@ -2474,6 +2476,24 @@ @@ -2474,6 +2476,24 @@
2474 _showLogoBug = showLogoBug; 2476 _showLogoBug = showLogoBug;
2475 } 2477 }
2476 2478
  2479 +- (void)tintColorDidChange
  2480 +{
  2481 + // update user dot
  2482 + //
  2483 + [self.userLocation updateTintColor];
  2484 +
  2485 + // update user halo
  2486 + //
  2487 + UIImage *haloImage = [self tintedTrackingDotHaloImage];
  2488 + _userHaloTrackingView.image = haloImage;
  2489 + [(RMMarker *)_trackingHaloAnnotation.layer replaceUIImage:haloImage];
  2490 +
  2491 + // update accuracy circle
  2492 + //
  2493 + ((RMCircle *)_accuracyCircleAnnotation.layer).lineColor = self.tintColor;
  2494 + ((RMCircle *)_accuracyCircleAnnotation.layer).fillColor = [self.tintColor colorWithAlphaComponent:0.15];
  2495 +}
  2496 +
2477 #pragma mark - 2497 #pragma mark -
2478 #pragma mark LatLng/Pixel translation functions 2498 #pragma mark LatLng/Pixel translation functions
2479 2499
@@ -3167,7 +3187,7 @@ @@ -3167,7 +3187,7 @@
3167 3187
3168 self.userLocation.layer.hidden = YES; 3188 self.userLocation.layer.hidden = YES;
3169 3189
3170 - _userHaloTrackingView = [[UIImageView alloc] initWithImage:[RMMapView resourceImageNamed:@"TrackingDotHalo.png"]]; 3190 + _userHaloTrackingView = [[UIImageView alloc] initWithImage:[self tintedTrackingDotHaloImage]];
3171 3191
3172 _userHaloTrackingView.center = CGPointMake(round([self bounds].size.width / 2), 3192 _userHaloTrackingView.center = CGPointMake(round([self bounds].size.width / 2),
3173 round([self bounds].size.height / 2)); 3193 round([self bounds].size.height / 2));
@@ -3298,8 +3318,8 @@ @@ -3298,8 +3318,8 @@
3298 _accuracyCircleAnnotation.layer.zPosition = -MAXFLOAT; 3318 _accuracyCircleAnnotation.layer.zPosition = -MAXFLOAT;
3299 _accuracyCircleAnnotation.isUserLocationAnnotation = YES; 3319 _accuracyCircleAnnotation.isUserLocationAnnotation = YES;
3300 3320
3301 - ((RMCircle *)_accuracyCircleAnnotation.layer).lineColor = [UIColor colorWithRed:0.378 green:0.552 blue:0.827 alpha:0.7];  
3302 - ((RMCircle *)_accuracyCircleAnnotation.layer).fillColor = [UIColor colorWithRed:0.378 green:0.552 blue:0.827 alpha:0.15]; 3321 + ((RMCircle *)_accuracyCircleAnnotation.layer).lineColor = self.tintColor;
  3322 + ((RMCircle *)_accuracyCircleAnnotation.layer).fillColor = [self.tintColor colorWithAlphaComponent:0.15];
3303 3323
3304 ((RMCircle *)_accuracyCircleAnnotation.layer).lineWidthInPixels = 2.0; 3324 ((RMCircle *)_accuracyCircleAnnotation.layer).lineWidthInPixels = 2.0;
3305 3325
@@ -3345,7 +3365,7 @@ @@ -3345,7 +3365,7 @@
3345 3365
3346 // create image marker 3366 // create image marker
3347 // 3367 //
3348 - _trackingHaloAnnotation.layer = [[RMMarker alloc] initWithUIImage:[RMMapView resourceImageNamed:@"TrackingDotHalo.png"]]; 3368 + _trackingHaloAnnotation.layer = [[RMMarker alloc] initWithUIImage:[self tintedTrackingDotHaloImage]];
3349 _trackingHaloAnnotation.layer.zPosition = -MAXFLOAT + 1; 3369 _trackingHaloAnnotation.layer.zPosition = -MAXFLOAT + 1;
3350 _trackingHaloAnnotation.isUserLocationAnnotation = YES; 3370 _trackingHaloAnnotation.isUserLocationAnnotation = YES;
3351 3371
@@ -3526,6 +3546,58 @@ @@ -3526,6 +3546,58 @@
3526 self.userTrackingMode = RMUserTrackingModeFollow; 3546 self.userTrackingMode = RMUserTrackingModeFollow;
3527 } 3547 }
3528 3548
  3549 +- (UIImage *)tintedTrackingDotHaloImage
  3550 +{
  3551 + UIImage *templateImage = [RMMapView resourceImageNamed:@"TrackingDotHalo.png"];
  3552 +
  3553 + CGRect rect = CGRectMake(0, 0, templateImage.size.width * templateImage.scale, templateImage.size.height * templateImage.scale);
  3554 +
  3555 + CIContext *context = [CIContext contextWithOptions:nil];
  3556 + CIImage *image = [CIImage imageWithCGImage:templateImage.CGImage];
  3557 + CIImage *result = nil;
  3558 +
  3559 + CIFilter *whitePointAdjust = [CIFilter filterWithName:@"CIWhitePointAdjust"];
  3560 + CIFilter *maximumComponent = [CIFilter filterWithName:@"CIMaximumComponent"];
  3561 + CIFilter *maskToAlpha = [CIFilter filterWithName:@"CIMaskToAlpha"];
  3562 +
  3563 + [maskToAlpha setValue:image forKey:kCIInputImageKey];
  3564 + result = [maskToAlpha valueForKey:kCIOutputImageKey];
  3565 +
  3566 + [whitePointAdjust setValue:result forKey:kCIInputImageKey];
  3567 + [whitePointAdjust setValue:[CIColor colorWithCGColor:self.tintColor.CGColor] forKey:kCIInputColorKey];
  3568 + result = [whitePointAdjust valueForKey:kCIOutputImageKey];
  3569 +
  3570 + CGImageRef haloImage = [context createCGImage:result fromRect:result.extent];
  3571 +
  3572 + [whitePointAdjust setValue:image forKey:kCIInputImageKey];
  3573 + [whitePointAdjust setValue:[CIColor colorWithRed:1 green:0 blue:0] forKey:kCIInputColorKey];
  3574 + result = [whitePointAdjust valueForKey:kCIOutputImageKey];
  3575 +
  3576 + [maximumComponent setValue:result forKey:kCIInputImageKey];
  3577 + result = [maximumComponent valueForKey:kCIOutputImageKey];
  3578 +
  3579 + [maskToAlpha setValue:result forKey:kCIInputImageKey];
  3580 + result = [maskToAlpha valueForKey:kCIOutputImageKey];
  3581 +
  3582 + CGImageRef ringImage = [context createCGImage:result fromRect:result.extent];
  3583 +
  3584 + rect = CGRectMake(0, 0, rect.size.width / templateImage.scale, rect.size.height / templateImage.scale);
  3585 +
  3586 + UIGraphicsBeginImageContextWithOptions(rect.size, NO, [[UIScreen mainScreen] scale]);
  3587 +
  3588 + CGContextRef c = UIGraphicsGetCurrentContext();
  3589 +
  3590 + CGContextDrawImage(c, rect, haloImage);
  3591 + CGContextDrawImage(c, rect, ringImage);
  3592 +
  3593 + UIImage *finalImage = UIGraphicsGetImageFromCurrentImageContext();
  3594 +
  3595 + UIGraphicsEndImageContext();
  3596 +
  3597 + return finalImage;
  3598 +}
  3599 +
  3600 +
3529 #pragma mark - 3601 #pragma mark -
3530 #pragma mark Attribution 3602 #pragma mark Attribution
3531 3603
@@ -70,7 +70,12 @@ @@ -70,7 +70,12 @@
70 self.hasCustomLayer = YES; 70 self.hasCustomLayer = YES;
71 71
72 if ( ! super.layer) 72 if ( ! super.layer)
73 - super.layer = [[RMMarker alloc] initWithUIImage:[RMMapView resourceImageNamed:@"TrackingDot.png"]]; 73 + {
  74 + if (RMPreVersion7)
  75 + super.layer = [[RMMarker alloc] initWithUIImage:[RMMapView resourceImageNamed:@"TrackingDot.png"]];
  76 + else
  77 + [self updateTintColor];
  78 + }
74 79
75 super.layer.zPosition = -MAXFLOAT + 2; 80 super.layer.zPosition = -MAXFLOAT + 2;
76 } 81 }
@@ -83,6 +88,32 @@ @@ -83,6 +88,32 @@
83 return (self.mapView.userTrackingMode != RMUserTrackingModeNone); 88 return (self.mapView.userTrackingMode != RMUserTrackingModeNone);
84 } 89 }
85 90
  91 +- (void)updateTintColor
  92 +{
  93 + if ( ! self.hasCustomLayer)
  94 + {
  95 + CGRect rect = CGRectMake(0, 0, 24, 24);
  96 +
  97 + UIGraphicsBeginImageContextWithOptions(rect.size, NO, [[UIScreen mainScreen] scale]);
  98 +
  99 + CGContextRef context = UIGraphicsGetCurrentContext();
  100 +
  101 + CGContextSetShadow(context, CGSizeMake(0, 0), 2);
  102 +
  103 + CGContextSetFillColorWithColor(context, [[UIColor whiteColor] CGColor]);
  104 + CGContextFillEllipseInRect(context, rect);
  105 +
  106 + CGContextSetShadowWithColor(context, CGSizeZero, 0, nil);
  107 +
  108 + CGContextSetFillColorWithColor(context, [self.mapView.tintColor CGColor]);
  109 + CGContextFillEllipseInRect(context, CGRectMake(rect.size.width / 6, rect.size.height / 6, rect.size.width * 2/3, rect.size.height * 2/3));
  110 +
  111 + super.layer = [[RMMarker alloc] initWithUIImage:UIGraphicsGetImageFromCurrentImageContext()];
  112 +
  113 + UIGraphicsEndImageContext();
  114 + }
  115 +}
  116 +
86 - (void)setLocation:(CLLocation *)newLocation 117 - (void)setLocation:(CLLocation *)newLocation
87 { 118 {
88 if ([newLocation distanceFromLocation:_location] && newLocation.coordinate.latitude != 0 && newLocation.coordinate.longitude != 0) 119 if ([newLocation distanceFromLocation:_location] && newLocation.coordinate.latitude != 0 && newLocation.coordinate.longitude != 0)

11.8 KB | W: | H:

9.07 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin

26.4 KB | W: | H:

31.4 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
@@ -114,6 +114,7 @@ @@ -114,6 +114,7 @@
114 DD5FA1EC15E2B020004EB6C5 /* RMLoadingTileView.m in Sources */ = {isa = PBXBuildFile; fileRef = DD5FA1EA15E2B020004EB6C5 /* RMLoadingTileView.m */; }; 114 DD5FA1EC15E2B020004EB6C5 /* RMLoadingTileView.m in Sources */ = {isa = PBXBuildFile; fileRef = DD5FA1EA15E2B020004EB6C5 /* RMLoadingTileView.m */; };
115 DD7C7E38164C894F0021CCA5 /* RMStaticMapView.h in Headers */ = {isa = PBXBuildFile; fileRef = DD7C7E36164C894F0021CCA5 /* RMStaticMapView.h */; settings = {ATTRIBUTES = (Public, ); }; }; 115 DD7C7E38164C894F0021CCA5 /* RMStaticMapView.h in Headers */ = {isa = PBXBuildFile; fileRef = DD7C7E36164C894F0021CCA5 /* RMStaticMapView.h */; settings = {ATTRIBUTES = (Public, ); }; };
116 DD7C7E39164C894F0021CCA5 /* RMStaticMapView.m in Sources */ = {isa = PBXBuildFile; fileRef = DD7C7E37164C894F0021CCA5 /* RMStaticMapView.m */; }; 116 DD7C7E39164C894F0021CCA5 /* RMStaticMapView.m in Sources */ = {isa = PBXBuildFile; fileRef = DD7C7E37164C894F0021CCA5 /* RMStaticMapView.m */; };
  117 + DD7ED619179DC1780022E1E1 /* CoreImage.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DD7ED618179DC1780022E1E1 /* CoreImage.framework */; };
117 DD8CDB4A14E0507100B73EB9 /* RMMapQuestOSMSource.h in Headers */ = {isa = PBXBuildFile; fileRef = DD8CDB4814E0507100B73EB9 /* RMMapQuestOSMSource.h */; settings = {ATTRIBUTES = (Private, ); }; }; 118 DD8CDB4A14E0507100B73EB9 /* RMMapQuestOSMSource.h in Headers */ = {isa = PBXBuildFile; fileRef = DD8CDB4814E0507100B73EB9 /* RMMapQuestOSMSource.h */; settings = {ATTRIBUTES = (Private, ); }; };
118 DD8CDB4B14E0507100B73EB9 /* RMMapQuestOSMSource.m in Sources */ = {isa = PBXBuildFile; fileRef = DD8CDB4914E0507100B73EB9 /* RMMapQuestOSMSource.m */; }; 119 DD8CDB4B14E0507100B73EB9 /* RMMapQuestOSMSource.m in Sources */ = {isa = PBXBuildFile; fileRef = DD8CDB4914E0507100B73EB9 /* RMMapQuestOSMSource.m */; };
119 DD8FD7541559E4A40044D96F /* RMUserLocation.h in Headers */ = {isa = PBXBuildFile; fileRef = DD8FD7521559E4A40044D96F /* RMUserLocation.h */; settings = {ATTRIBUTES = (Public, ); }; }; 120 DD8FD7541559E4A40044D96F /* RMUserLocation.h in Headers */ = {isa = PBXBuildFile; fileRef = DD8FD7521559E4A40044D96F /* RMUserLocation.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -286,6 +287,7 @@ @@ -286,6 +287,7 @@
286 DD6A83751644A20C0097F31F /* MapBox.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MapBox.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; 287 DD6A83751644A20C0097F31F /* MapBox.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MapBox.bundle; sourceTree = BUILT_PRODUCTS_DIR; };
287 DD7C7E36164C894F0021CCA5 /* RMStaticMapView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMStaticMapView.h; sourceTree = "<group>"; }; 288 DD7C7E36164C894F0021CCA5 /* RMStaticMapView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMStaticMapView.h; sourceTree = "<group>"; };
288 DD7C7E37164C894F0021CCA5 /* RMStaticMapView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMStaticMapView.m; sourceTree = "<group>"; }; 289 DD7C7E37164C894F0021CCA5 /* RMStaticMapView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMStaticMapView.m; sourceTree = "<group>"; };
  290 + DD7ED618179DC1780022E1E1 /* CoreImage.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreImage.framework; path = System/Library/Frameworks/CoreImage.framework; sourceTree = SDKROOT; };
289 DD8CDB4814E0507100B73EB9 /* RMMapQuestOSMSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMMapQuestOSMSource.h; sourceTree = "<group>"; }; 291 DD8CDB4814E0507100B73EB9 /* RMMapQuestOSMSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMMapQuestOSMSource.h; sourceTree = "<group>"; };
290 DD8CDB4914E0507100B73EB9 /* RMMapQuestOSMSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMMapQuestOSMSource.m; sourceTree = "<group>"; }; 292 DD8CDB4914E0507100B73EB9 /* RMMapQuestOSMSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMMapQuestOSMSource.m; sourceTree = "<group>"; };
291 DD8FD7521559E4A40044D96F /* RMUserLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMUserLocation.h; sourceTree = "<group>"; }; 293 DD8FD7521559E4A40044D96F /* RMUserLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMUserLocation.h; sourceTree = "<group>"; };
@@ -343,6 +345,7 @@ @@ -343,6 +345,7 @@
343 files = ( 345 files = (
344 B8C974500E8A19B2007D16AD /* CoreFoundation.framework in Frameworks */, 346 B8C974500E8A19B2007D16AD /* CoreFoundation.framework in Frameworks */,
345 B8C974510E8A19B2007D16AD /* CoreGraphics.framework in Frameworks */, 347 B8C974510E8A19B2007D16AD /* CoreGraphics.framework in Frameworks */,
  348 + DD7ED619179DC1780022E1E1 /* CoreImage.framework in Frameworks */,
346 B8C974520E8A19B2007D16AD /* CoreLocation.framework in Frameworks */, 349 B8C974520E8A19B2007D16AD /* CoreLocation.framework in Frameworks */,
347 B8C974530E8A19B2007D16AD /* UIKit.framework in Frameworks */, 350 B8C974530E8A19B2007D16AD /* UIKit.framework in Frameworks */,
348 B8C974540E8A19B2007D16AD /* QuartzCore.framework in Frameworks */, 351 B8C974540E8A19B2007D16AD /* QuartzCore.framework in Frameworks */,
@@ -424,6 +427,7 @@ @@ -424,6 +427,7 @@
424 children = ( 427 children = (
425 B83E65590E80E7EB001663B6 /* CoreFoundation.framework */, 428 B83E65590E80E7EB001663B6 /* CoreFoundation.framework */,
426 288765A40DF7441C002DB57D /* CoreGraphics.framework */, 429 288765A40DF7441C002DB57D /* CoreGraphics.framework */,
  430 + DD7ED618179DC1780022E1E1 /* CoreImage.framework */,
427 B83E65630E80E81C001663B6 /* CoreLocation.framework */, 431 B83E65630E80E81C001663B6 /* CoreLocation.framework */,
428 1D30AB110D05D00D00671497 /* Foundation.framework */, 432 1D30AB110D05D00D00671497 /* Foundation.framework */,
429 B83E65680E80E830001663B6 /* QuartzCore.framework */, 433 B83E65680E80E830001663B6 /* QuartzCore.framework */,