Skip to content

Instantly share code, notes, and snippets.

@CoderXL
Forked from maciekish/MKMapView+MoveLogo.h
Created February 13, 2014 00:25
Show Gist options
  • Select an option

  • Save CoderXL/8967368 to your computer and use it in GitHub Desktop.

Select an option

Save CoderXL/8967368 to your computer and use it in GitHub Desktop.
//
// 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