Created
July 8, 2013 08:45
-
-
Save maciekish/5947238 to your computer and use it in GitHub Desktop.
This category allows you to move the MKMapView logo so that it remains visible if you put other stuff on the mapview. If the logo is hidden, the app won't pass the App Store review. Tested with iOS 5 through 7.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// MKMapView+MoveLogo.h | |
// | |
// Created by Maciej Swic on 2013-07-08. | |
// Released under the MIT license. | |
// | |
// This category allows you to move the MKMapView logo so that it remains visible if you | |
// put other stuff on the mapview. If the logo is hidden, the app won't pass the App Store | |
// review. Tested with iOS 5 through 7. | |
// | |
#import <MapKit/MapKit.h> | |
@interface MKMapView (MoveLogo) | |
- (void)moveLogoByOffset:(CGPoint)offset; | |
- (void)moveLogoToPoint:(CGPoint)point; | |
- (UIView*)logo; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// MKMapView+MoveLogo.m | |
// Shield | |
// | |
// Created by Maciej Swic on 2013-07-08. | |
// Released under the MIT license. | |
// | |
#import "MKMapView+MoveLogo.h" | |
@implementation MKMapView (MoveLogo) | |
- (void)moveLogoByOffset:(CGPoint)offset { | |
UIView* logo = [self logo]; | |
logo.frame = CGRectOffset(logo.frame, offset.x, offset.y); | |
} | |
- (void)moveLogoToPoint:(CGPoint)point { | |
UIView* logo = [self logo]; | |
logo.frame = CGRectMake(point.x, point.y, logo.frame.size.width, logo.frame.size.height); | |
} | |
- (UIView*)logo { | |
UIView* logo; | |
//Google Maps | |
for (UIView *subview in self.subviews) { | |
if ([subview isMemberOfClass:[UIImageView class]]) { | |
logo = (UIView*)subview; | |
break; | |
} | |
} | |
//If we're on Apple Maps, there is no UIImageView. | |
if (!logo) { | |
for (UIView *subview in self.subviews) | |
if ([subview isKindOfClass:[UILabel class]]) { | |
logo = (UIView*)subview; | |
break; | |
} | |
} | |
return logo; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment