Skip to content

Instantly share code, notes, and snippets.

@maciekish
Created July 8, 2013 08:45
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save maciekish/5947238 to your computer and use it in GitHub Desktop.
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.
//
// 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
//
// 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