Skip to content

Instantly share code, notes, and snippets.

@DwightChan
Forked from maciekish/MKMapView+MoveLogo.h
Created October 14, 2016 12:33
Show Gist options
  • Select an option

  • Save DwightChan/03aab541349d26f232dc1a2e39e1a8b9 to your computer and use it in GitHub Desktop.

Select an option

Save DwightChan/03aab541349d26f232dc1a2e39e1a8b9 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