proper iOS 7 heading angle tinting
Showing
8 changed files
with
53 additions
and
7 deletions
@@ -3403,7 +3403,7 @@ | @@ -3403,7 +3403,7 @@ | ||
3403 | 3403 | ||
3404 | [self insertSubview:_userHaloTrackingView belowSubview:_overlayView]; | 3404 | [self insertSubview:_userHaloTrackingView belowSubview:_overlayView]; |
3405 | 3405 | ||
3406 | - _userHeadingTrackingView = [[UIImageView alloc] initWithImage:[RMMapView resourceImageNamed:@"HeadingAngleLarge.png"]]; | 3406 | + _userHeadingTrackingView = [[UIImageView alloc] initWithImage:[self headingAngleImageForAccuracy:MAXFLOAT]]; |
3407 | 3407 | ||
3408 | _userHeadingTrackingView.frame = CGRectMake((self.bounds.size.width / 2) - (_userHeadingTrackingView.bounds.size.width / 2), | 3408 | _userHeadingTrackingView.frame = CGRectMake((self.bounds.size.width / 2) - (_userHeadingTrackingView.bounds.size.width / 2), |
3409 | (self.bounds.size.height / 2) - _userHeadingTrackingView.bounds.size.height, | 3409 | (self.bounds.size.height / 2) - _userHeadingTrackingView.bounds.size.height, |
@@ -3651,12 +3651,7 @@ | @@ -3651,12 +3651,7 @@ | ||
3651 | if ( ! _showsUserLocation || _mapScrollView.isDragging || newHeading.headingAccuracy < 0) | 3651 | if ( ! _showsUserLocation || _mapScrollView.isDragging || newHeading.headingAccuracy < 0) |
3652 | return; | 3652 | return; |
3653 | 3653 | ||
3654 | - if (newHeading.headingAccuracy > 40) | ||
3655 | - _userHeadingTrackingView.image = [RMMapView resourceImageNamed:@"HeadingAngleLarge.png"]; | ||
3656 | - else if (newHeading.headingAccuracy >= 25 && newHeading.headingAccuracy <= 40) | ||
3657 | - _userHeadingTrackingView.image = [RMMapView resourceImageNamed:@"HeadingAngleMedium.png"]; | ||
3658 | - else | ||
3659 | - _userHeadingTrackingView.image = [RMMapView resourceImageNamed:@"HeadingAngleSmall.png"]; | 3654 | + _userHeadingTrackingView.image = [self headingAngleImageForAccuracy:newHeading.headingAccuracy]; |
3660 | 3655 | ||
3661 | self.userLocation.heading = newHeading; | 3656 | self.userLocation.heading = newHeading; |
3662 | 3657 | ||
@@ -3777,6 +3772,33 @@ | @@ -3777,6 +3772,33 @@ | ||
3777 | } | 3772 | } |
3778 | } | 3773 | } |
3779 | 3774 | ||
3775 | +- (UIImage *)headingAngleImageForAccuracy:(CLLocationDirection)accuracy | ||
3776 | +{ | ||
3777 | + NSString *sizeString; | ||
3778 | + | ||
3779 | + if (accuracy > 40) | ||
3780 | + sizeString = @"Large"; | ||
3781 | + else if (accuracy >= 25 && accuracy <= 40) | ||
3782 | + sizeString = @"Medium"; | ||
3783 | + else | ||
3784 | + sizeString = @"Small"; | ||
3785 | + | ||
3786 | + UIImage *headingAngleImage = [RMMapView resourceImageNamed:[NSString stringWithFormat:@"HeadingAngle%@%@.png", (RMPostVersion7 ? @"Mask" : @""), sizeString]]; | ||
3787 | + | ||
3788 | + if (RMPostVersion7) | ||
3789 | + { | ||
3790 | + UIGraphicsBeginImageContextWithOptions(headingAngleImage.size, NO, [[UIScreen mainScreen] scale]); | ||
3791 | + [headingAngleImage drawAtPoint:CGPointMake(0, 0)]; | ||
3792 | + CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeSourceIn); | ||
3793 | + CGContextSetFillColorWithColor(UIGraphicsGetCurrentContext(), [self.tintColor CGColor]); | ||
3794 | + CGContextFillRect(UIGraphicsGetCurrentContext(), CGRectMake(0, 0, headingAngleImage.size.width, headingAngleImage.size.height)); | ||
3795 | + headingAngleImage = UIGraphicsGetImageFromCurrentImageContext(); | ||
3796 | + UIGraphicsEndImageContext(); | ||
3797 | + } | ||
3798 | + | ||
3799 | + return headingAngleImage; | ||
3800 | +} | ||
3801 | + | ||
3780 | - (void)setUserTrackingBarButtonItem:(RMUserTrackingBarButtonItem *)userTrackingBarButtonItem | 3802 | - (void)setUserTrackingBarButtonItem:(RMUserTrackingBarButtonItem *)userTrackingBarButtonItem |
3781 | { | 3803 | { |
3782 | _userTrackingBarButtonItem = userTrackingBarButtonItem; | 3804 | _userTrackingBarButtonItem = userTrackingBarButtonItem; |
3.37 KB
11.8 KB
2.19 KB
6.21 KB
1.7 KB
4.71 KB
@@ -83,6 +83,12 @@ | @@ -83,6 +83,12 @@ | ||
83 | B8F3FC650EA2E792004D8F85 /* RMMarker.m in Sources */ = {isa = PBXBuildFile; fileRef = B8F3FC630EA2E792004D8F85 /* RMMarker.m */; }; | 83 | B8F3FC650EA2E792004D8F85 /* RMMarker.m in Sources */ = {isa = PBXBuildFile; fileRef = B8F3FC630EA2E792004D8F85 /* RMMarker.m */; }; |
84 | D1437B36122869E400888DAE /* RMDBMapSource.m in Sources */ = {isa = PBXBuildFile; fileRef = D1437B32122869E400888DAE /* RMDBMapSource.m */; }; | 84 | D1437B36122869E400888DAE /* RMDBMapSource.m in Sources */ = {isa = PBXBuildFile; fileRef = D1437B32122869E400888DAE /* RMDBMapSource.m */; }; |
85 | D1437B37122869E400888DAE /* RMDBMapSource.h in Headers */ = {isa = PBXBuildFile; fileRef = D1437B33122869E400888DAE /* RMDBMapSource.h */; settings = {ATTRIBUTES = (Private, ); }; }; | 85 | D1437B37122869E400888DAE /* RMDBMapSource.h in Headers */ = {isa = PBXBuildFile; fileRef = D1437B33122869E400888DAE /* RMDBMapSource.h */; settings = {ATTRIBUTES = (Private, ); }; }; |
86 | + DD07A23817F3AF9800E420B2 /* HeadingAngleMaskSmall.png in Resources */ = {isa = PBXBuildFile; fileRef = DD07A23217F3AF9800E420B2 /* HeadingAngleMaskSmall.png */; }; | ||
87 | + DD07A23917F3AF9800E420B2 /* HeadingAngleMaskMedium.png in Resources */ = {isa = PBXBuildFile; fileRef = DD07A23317F3AF9800E420B2 /* HeadingAngleMaskMedium.png */; }; | ||
88 | + DD07A23A17F3AF9800E420B2 /* HeadingAngleMaskLarge.png in Resources */ = {isa = PBXBuildFile; fileRef = DD07A23417F3AF9800E420B2 /* HeadingAngleMaskLarge.png */; }; | ||
89 | + DD07A23B17F3AF9800E420B2 /* HeadingAngleMaskSmall@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = DD07A23517F3AF9800E420B2 /* HeadingAngleMaskSmall@2x.png */; }; | ||
90 | + DD07A23C17F3AF9800E420B2 /* HeadingAngleMaskMedium@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = DD07A23617F3AF9800E420B2 /* HeadingAngleMaskMedium@2x.png */; }; | ||
91 | + DD07A23D17F3AF9800E420B2 /* HeadingAngleMaskLarge@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = DD07A23717F3AF9800E420B2 /* HeadingAngleMaskLarge@2x.png */; }; | ||
86 | DD1985C1165C5F6400DF667F /* RMTileMillSource.h in Headers */ = {isa = PBXBuildFile; fileRef = DD1985BF165C5F6400DF667F /* RMTileMillSource.h */; settings = {ATTRIBUTES = (Public, ); }; }; | 92 | DD1985C1165C5F6400DF667F /* RMTileMillSource.h in Headers */ = {isa = PBXBuildFile; fileRef = DD1985BF165C5F6400DF667F /* RMTileMillSource.h */; settings = {ATTRIBUTES = (Public, ); }; }; |
87 | DD1985C2165C5F6400DF667F /* RMTileMillSource.m in Sources */ = {isa = PBXBuildFile; fileRef = DD1985C0165C5F6400DF667F /* RMTileMillSource.m */; }; | 93 | DD1985C2165C5F6400DF667F /* RMTileMillSource.m in Sources */ = {isa = PBXBuildFile; fileRef = DD1985C0165C5F6400DF667F /* RMTileMillSource.m */; }; |
88 | DD1E3C6E161F954F004FC649 /* SMCalloutView.h in Headers */ = {isa = PBXBuildFile; fileRef = DD1E3C6C161F954F004FC649 /* SMCalloutView.h */; }; | 94 | DD1E3C6E161F954F004FC649 /* SMCalloutView.h in Headers */ = {isa = PBXBuildFile; fileRef = DD1E3C6C161F954F004FC649 /* SMCalloutView.h */; }; |
@@ -257,6 +263,12 @@ | @@ -257,6 +263,12 @@ | ||
257 | B8F3FC630EA2E792004D8F85 /* RMMarker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMMarker.m; sourceTree = "<group>"; }; | 263 | B8F3FC630EA2E792004D8F85 /* RMMarker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMMarker.m; sourceTree = "<group>"; }; |
258 | D1437B32122869E400888DAE /* RMDBMapSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMDBMapSource.m; sourceTree = "<group>"; }; | 264 | D1437B32122869E400888DAE /* RMDBMapSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMDBMapSource.m; sourceTree = "<group>"; }; |
259 | D1437B33122869E400888DAE /* RMDBMapSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMDBMapSource.h; sourceTree = "<group>"; }; | 265 | D1437B33122869E400888DAE /* RMDBMapSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMDBMapSource.h; sourceTree = "<group>"; }; |
266 | + DD07A23217F3AF9800E420B2 /* HeadingAngleMaskSmall.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = HeadingAngleMaskSmall.png; path = Map/Resources/HeadingAngleMaskSmall.png; sourceTree = "<group>"; }; | ||
267 | + DD07A23317F3AF9800E420B2 /* HeadingAngleMaskMedium.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = HeadingAngleMaskMedium.png; path = Map/Resources/HeadingAngleMaskMedium.png; sourceTree = "<group>"; }; | ||
268 | + DD07A23417F3AF9800E420B2 /* HeadingAngleMaskLarge.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = HeadingAngleMaskLarge.png; path = Map/Resources/HeadingAngleMaskLarge.png; sourceTree = "<group>"; }; | ||
269 | + DD07A23517F3AF9800E420B2 /* HeadingAngleMaskSmall@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "HeadingAngleMaskSmall@2x.png"; path = "Map/Resources/HeadingAngleMaskSmall@2x.png"; sourceTree = "<group>"; }; | ||
270 | + DD07A23617F3AF9800E420B2 /* HeadingAngleMaskMedium@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "HeadingAngleMaskMedium@2x.png"; path = "Map/Resources/HeadingAngleMaskMedium@2x.png"; sourceTree = "<group>"; }; | ||
271 | + DD07A23717F3AF9800E420B2 /* HeadingAngleMaskLarge@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "HeadingAngleMaskLarge@2x.png"; path = "Map/Resources/HeadingAngleMaskLarge@2x.png"; sourceTree = "<group>"; }; | ||
260 | DD1985BF165C5F6400DF667F /* RMTileMillSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMTileMillSource.h; sourceTree = "<group>"; }; | 272 | DD1985BF165C5F6400DF667F /* RMTileMillSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMTileMillSource.h; sourceTree = "<group>"; }; |
261 | DD1985C0165C5F6400DF667F /* RMTileMillSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMTileMillSource.m; sourceTree = "<group>"; }; | 273 | DD1985C0165C5F6400DF667F /* RMTileMillSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMTileMillSource.m; sourceTree = "<group>"; }; |
262 | DD1E3C6C161F954F004FC649 /* SMCalloutView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SMCalloutView.h; path = SMCalloutView/SMCalloutView.h; sourceTree = "<group>"; }; | 274 | DD1E3C6C161F954F004FC649 /* SMCalloutView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SMCalloutView.h; path = SMCalloutView/SMCalloutView.h; sourceTree = "<group>"; }; |
@@ -640,6 +652,12 @@ | @@ -640,6 +652,12 @@ | ||
640 | DD94D46916C2E064003D5739 /* HeadingAngleMedium@2x.png */, | 652 | DD94D46916C2E064003D5739 /* HeadingAngleMedium@2x.png */, |
641 | DD94D46616C2E064003D5739 /* HeadingAngleLarge.png */, | 653 | DD94D46616C2E064003D5739 /* HeadingAngleLarge.png */, |
642 | DD94D46716C2E064003D5739 /* HeadingAngleLarge@2x.png */, | 654 | DD94D46716C2E064003D5739 /* HeadingAngleLarge@2x.png */, |
655 | + DD07A23217F3AF9800E420B2 /* HeadingAngleMaskSmall.png */, | ||
656 | + DD07A23517F3AF9800E420B2 /* HeadingAngleMaskSmall@2x.png */, | ||
657 | + DD07A23317F3AF9800E420B2 /* HeadingAngleMaskMedium.png */, | ||
658 | + DD07A23617F3AF9800E420B2 /* HeadingAngleMaskMedium@2x.png */, | ||
659 | + DD07A23417F3AF9800E420B2 /* HeadingAngleMaskLarge.png */, | ||
660 | + DD07A23717F3AF9800E420B2 /* HeadingAngleMaskLarge@2x.png */, | ||
643 | DD932BAB165C287000D69D49 /* LoadingTile.png */, | 661 | DD932BAB165C287000D69D49 /* LoadingTile.png */, |
644 | DDC8D28517E92ED100A4FB32 /* LoadingTile6.png */, | 662 | DDC8D28517E92ED100A4FB32 /* LoadingTile6.png */, |
645 | DD932BA7165C287000D69D49 /* TrackingDot.png */, | 663 | DD932BA7165C287000D69D49 /* TrackingDot.png */, |
@@ -848,6 +866,9 @@ | @@ -848,6 +866,9 @@ | ||
848 | DD932BB3165C287000D69D49 /* mapbox.png in Resources */, | 866 | DD932BB3165C287000D69D49 /* mapbox.png in Resources */, |
849 | DD932BB4165C287000D69D49 /* mapbox@2x.png in Resources */, | 867 | DD932BB4165C287000D69D49 /* mapbox@2x.png in Resources */, |
850 | DD932BB7165C287000D69D49 /* HeadingAngleSmall.png in Resources */, | 868 | DD932BB7165C287000D69D49 /* HeadingAngleSmall.png in Resources */, |
869 | + DD07A23A17F3AF9800E420B2 /* HeadingAngleMaskLarge.png in Resources */, | ||
870 | + DD07A23C17F3AF9800E420B2 /* HeadingAngleMaskMedium@2x.png in Resources */, | ||
871 | + DD07A23917F3AF9800E420B2 /* HeadingAngleMaskMedium.png in Resources */, | ||
851 | DDA257071798A95600BBB325 /* Compass@2x.png in Resources */, | 872 | DDA257071798A95600BBB325 /* Compass@2x.png in Resources */, |
852 | DD932BB8165C287000D69D49 /* HeadingAngleSmall@2x.png in Resources */, | 873 | DD932BB8165C287000D69D49 /* HeadingAngleSmall@2x.png in Resources */, |
853 | DD932BB9165C287000D69D49 /* LoadingTile.png in Resources */, | 874 | DD932BB9165C287000D69D49 /* LoadingTile.png in Resources */, |
@@ -870,11 +891,14 @@ | @@ -870,11 +891,14 @@ | ||
870 | DDA257011798A95600BBB325 /* TrackingLocationOffMaskLandscape@2x.png in Resources */, | 891 | DDA257011798A95600BBB325 /* TrackingLocationOffMaskLandscape@2x.png in Resources */, |
871 | DDA257041798A95600BBB325 /* TrackingLocationMask@2x.png in Resources */, | 892 | DDA257041798A95600BBB325 /* TrackingLocationMask@2x.png in Resources */, |
872 | DDA257081798A95600BBB325 /* Compass.png in Resources */, | 893 | DDA257081798A95600BBB325 /* Compass.png in Resources */, |
894 | + DD07A23817F3AF9800E420B2 /* HeadingAngleMaskSmall.png in Resources */, | ||
873 | DD94D46A16C2E064003D5739 /* HeadingAngleLarge.png in Resources */, | 895 | DD94D46A16C2E064003D5739 /* HeadingAngleLarge.png in Resources */, |
874 | DD94D46B16C2E064003D5739 /* HeadingAngleLarge@2x.png in Resources */, | 896 | DD94D46B16C2E064003D5739 /* HeadingAngleLarge@2x.png in Resources */, |
897 | + DD07A23D17F3AF9800E420B2 /* HeadingAngleMaskLarge@2x.png in Resources */, | ||
875 | DD94D46C16C2E064003D5739 /* HeadingAngleMedium.png in Resources */, | 898 | DD94D46C16C2E064003D5739 /* HeadingAngleMedium.png in Resources */, |
876 | DD94D46D16C2E064003D5739 /* HeadingAngleMedium@2x.png in Resources */, | 899 | DD94D46D16C2E064003D5739 /* HeadingAngleMedium@2x.png in Resources */, |
877 | DD280D1416EFDDD30014B549 /* examples.map-z2effxa8.json in Resources */, | 900 | DD280D1416EFDDD30014B549 /* examples.map-z2effxa8.json in Resources */, |
901 | + DD07A23B17F3AF9800E420B2 /* HeadingAngleMaskSmall@2x.png in Resources */, | ||
878 | DD36766B17D94F980001F27B /* mapbox-logo@2x.png in Resources */, | 902 | DD36766B17D94F980001F27B /* mapbox-logo@2x.png in Resources */, |
879 | DDA257021798A95600BBB325 /* TrackingLocationOffMask@2x.png in Resources */, | 903 | DDA257021798A95600BBB325 /* TrackingLocationOffMask@2x.png in Resources */, |
880 | ); | 904 | ); |
-
Please register or login to post a comment